parsimoney
A strict money parser. Reads what humans write, preserves what they meant.
from parsimoney import parse_money
parse_money("$45.00") # Money(amount=45.0, currency="$", iso=None)
parse_money("45 dollars") # Money(amount=45.0, currency="dollars", iso=None, currency_after=True)
parse_money("EUR 1,234.56") # Money(amount=1234.56, currency="EUR", iso="EUR")
parse_money("\u20ac100") # Money(amount=100.0, currency="\u20ac", iso="EUR")
parse_money("1000 yen") # Money(amount=1000.0, currency="yen", iso="JPY")
Strict: the entire input must be accounted for. No silent data loss.
parse_money("$45.00 worth of stuff") # raises ValueError
ISO Resolution
Unambiguous currencies resolve automatically. Ambiguous ones like $
and "dollars" (USD? CAD? AUD?) resolve via application-provided defaults
or locale:
parse_money("$100", defaults={"$": "CAD"})
# Money(amount=100.0, currency="$", iso="CAD")
parse_money("100 dollars", defaults={"dollars": "AUD"})
# Money(amount=100.0, currency="dollars", iso="AUD", currency_after=True)
Without an explicit default, ambiguous currencies check the system
locale. If the locale doesn't resolve it either, iso is None -
parsimoney never guesses.
CLI
$ python -m parsimoney '$45.00' '100 euros' '1,234 USD'
'$45.00' -> $45
'100 euros' -> 100 euros
'1,234 USD' -> 1234 USD
Metadata
Release files for parsimoney 0.4.1
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 |
|---|---|---|---|---|
| parsimoney-0.4.1.tar.gz | 18.4 kB | Without provenance | Details for parsimoney-0.4.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| parsimoney-0.4.1-py3-none-any.whl | Python 3 | none | any | Details for parsimoney-0.4.1-py3-none-any.whl |
Total release size: 39.0 kB
Release files / parsimoney-0.4.1.tar.gz
| Download URL | parsimoney-0.4.1.tar.gz |
|---|---|
| Size | 18.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0fb9604587840c07da489f2ede28f71a65382bdf86bf6972c08c8e6b23a4240c
|
|
BLAKE2b-256 checksum How to use checksums |
f2601a2f51db705349b7bd97bfe435167f8ba825cc5ecd466c6ae4a504139098
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.2 CPython/3.12.3 Linux/6.8.0-117-generic
|
Release files / parsimoney-0.4.1-py3-none-any.whl
| Download URL | parsimoney-0.4.1-py3-none-any.whl |
|---|---|
| Size | 20.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b74b205c12ad33d6e0b2bf0e2dbefe98a4d7007789ecb979cb322bee9dc8059c
|
|
BLAKE2b-256 checksum How to use checksums |
618a5d2720b7189162178b1f3078841048338d49f37c965c3ecf339ef8766b79
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.2 CPython/3.12.3 Linux/6.8.0-117-generic
|
Security for parsimoney 0.4.1
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.