Registry / serialization / prices

prices

JSON →
library1.1.1pypypi✓ verified 82d ago

Python price handling for humans. Provides a Price class with arithmetic operations, currency support, tax calculation, and discount application. Current version: 1.1.1. Release cadence: infrequent, last release 2021.

pip install prices
INSTALL
IMPORT
SIG · PRICES
P
prices
serializationpythonv1.1.1
Install
2.1s avg
Import
Disk
49MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 50.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.1s · import 0.000s · 51MB
49MB installed
● package 49MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Money
from prices import Money
from prices import Price
TaxedMoney
from prices import TaxedMoney
discount
from prices import discount

Basic usage of Price, PriceRange, and TaxedMoney classes.

from prices import Price, Money, TaxedMoney, PriceRange # Create a price price = Price(currency='USD', net=Money(10, 'USD'), gross=Money(12, 'USD')) print(price) # Price arithmetic p1 = Price(currency='USD', net=Money(5, 'USD'), gross=Money(6, 'USD')) p2 = Price(currency='USD', net=Money(3, 'USD'), gross=Money(4, 'USD')) print(p1 + p2) # Create a price range pr = PriceRange(start=p1, stop=p2) print(pr) # TaxedMoney tm = TaxedMoney(net=Money(100, 'USD'), gross=Money(123, 'USD')) print(tm)
Debug
Known issues
gotchaCurrency is required on Price and Money. If you omit currency, you'll get a TypeError.
fix
Always specify currency, e.g., Price(currency='USD', net=..., gross=...).
affects: all
breakingIn version 0.5, Price and PriceRange became named tuples. Accessing attributes like .currency still works, but they are immutable.
fix
Use the named tuple interface: price = Price(currency='USD', net=10, gross=12); price.net works, but price.net = 5 raises AttributeError.
affects: >=0.5
Upgrade
Version history
1.1.1latest on PyPI · released Oct 7, 2022
Audit
Dependencies
babeloptionalOptional dependency for formatting prices with locale
Agent activity
10 hits · last 30 days
node
10
Resources
prices — pip install prices · libregistry