dice_parser
Arithmetic expressions with dice roll support.
dice_parser evaluates integer arithmetic expressions and common tabletop dice
notation such as d20, 2d6, 6d6h3, and 2d20L(1d1). It also keeps a
readable representation of the rolls used to compute the final value.
Installation
pip install dice-parser
Usage
from dice_parser.parser import DiceParser
parser = DiceParser()
result = parser.parse("2d6 + 4")
print(result.value)
print(result.string)
The result is a ParseResult object with two fields:
value: the evaluated integer value.string: a readable expression showing the dice that were rolled.
Supported Syntax
parser.parse("3 * 4 + 12 / 3 + (3 - 2)")
parser.parse("d20")
parser.parse("2d6 + 4")
parser.parse("6d6h3")
parser.parse("2d20L(1d1)")
parser.parse("a=2+2")
parser.parse("d a")
Metadata
Release files for dice-parser 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dice_parser-1.1.0.tar.gz | 4.8 kB | Without provenance | Details for dice_parser-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dice_parser-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for dice_parser-1.1.0-py3-none-any.whl |
Total release size: 11.2 kB
Release files / dice_parser-1.1.0.tar.gz
| Download URL | dice_parser-1.1.0.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b66891cf18e492c1eeaf8b68f1d4e4f6876d204d39cd89e40f37e5681ff5cd5a
|
|
BLAKE2b-256 checksum How to use checksums |
fb4b1a15235b833d2b1fc7ac2a9451c6db5072290db6a7ba1a9a9dfbd0b7d387
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.4 CPython/3.12.5 Linux/6.6.87.2-microsoft-standard-WSL2
|
Release files / dice_parser-1.1.0-py3-none-any.whl
| Download URL | dice_parser-1.1.0-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7ca4dd5e4f71552c250d552209fde50d2a740c615b4a37cb45c37cf0876ddba4
|
|
BLAKE2b-256 checksum How to use checksums |
f2bac14c11ce1b6ea41e37b7cc1a9bcbd48ef4ac80a50a78a3fde4d3707508a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.4 CPython/3.12.5 Linux/6.6.87.2-microsoft-standard-WSL2
|
Security for dice-parser 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.