Skip to main content

Dragn Logo

Supported Python versions PyPI version Build Status Codecoverage Licence Code style: Black Downloads


Roll dice in your python programs


Why?

I wanted a better API to rolling dice using Python, and the usual random.randint is very good, but doesn't really represent rolling dice quite the way I imagine it.

This was a good learning experiment, but I'm not expecting anyone to use it.

Who is this for?

People building RPGs, or games that would involve dice and who care about how their code looks like.

I may be biased, but I really believe that this library provides a much better interface than pure random.randint.

How to install

$ pip install dragn

How to use

>> from dragn.dice import D4, D6, D8
>>> D6()
1
>>> f"You roll the die and the result is {D8()}"
'You roll the die and the result is 4'
>>> f"You roll 3 dice and you get {[D8() for _ in range(3)]}"
>>> 'You roll 3 dice and you get [3, 1, 8]'
>>> four_dice = D4 * 4
>>> f"You roll 4 dice and the results are {four_dice()}"
'You roll 4 dice and the results are (4, 3, 1, 2)'
>>> f"You roll two dice and the results are {two_dice()}"
'You roll two dice and the results are (3, 4)'
>>> dice_tower = (D6 * 2) + D4
>>> f"You roll two D6 and a D4 and check the results {dice_tower()}"
'You roll two D6 and a D4 and check the results (2, 2, 6)'

For more examples, check the tests

Metadata

Release files for dragn 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dragn 0.4.0
File Size Uploaded
dragn-0.4.0.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dragn 0.4.0
File Interpreter ABI Platform
dragn-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.4 kB

Release files / dragn-0.4.0.tar.gz

Download URL dragn-0.4.0.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d970ceb7e5363934a1cb7c963e518858527e38d2e1267f11269a5ff305a72d6b
BLAKE2b-256 checksum
How to use checksums
3e0d31ea6812695c6c81e7813da5c012f7a86b560aed990b16ba92169d1649db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.7.4

Release files / dragn-0.4.0-py3-none-any.whl

Download URL dragn-0.4.0-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bcd2e0178179ded491fd2259b6e6692ca4b70ee492091cd674668806d4f65fce
BLAKE2b-256 checksum
How to use checksums
344517d0a3d2ff336de6ccc4b0a3f687bd0af7f9ca79942a163358d5bc808585
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.7.4

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page