{"id":24264,"library":"prices","title":"prices","description":"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.","status":"active","version":"1.1.1","language":"python","source_language":"en","source_url":"https://github.com/mirumee/prices","tags":["price","currency","money","discount","prices"],"install":[{"cmd":"pip install prices","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Optional dependency for formatting prices with locale","package":"babel","optional":true}],"imports":[{"note":"","wrong":null,"symbol":"Price","correct":"from prices import Price"},{"note":"","wrong":null,"symbol":"Money","correct":"from prices import Money"},{"note":"","wrong":null,"symbol":"PriceRange","correct":"from prices import PriceRange"},{"note":"","wrong":null,"symbol":"TaxedMoney","correct":"from prices import TaxedMoney"},{"note":"","wrong":null,"symbol":"FixedDiscount","correct":"from prices.discounts import FixedDiscount"},{"note":"","wrong":null,"symbol":"PercentageDiscount","correct":"from prices.discounts import PercentageDiscount"}],"quickstart":{"code":"from prices import Price, Money, TaxedMoney, PriceRange\n\n# Create a price\nprice = Price(currency='USD', net=Money(10, 'USD'), gross=Money(12, 'USD'))\nprint(price)\n\n# Price arithmetic\np1 = Price(currency='USD', net=Money(5, 'USD'), gross=Money(6, 'USD'))\np2 = Price(currency='USD', net=Money(3, 'USD'), gross=Money(4, 'USD'))\nprint(p1 + p2)\n\n# Create a price range\npr = PriceRange(start=p1, stop=p2)\nprint(pr)\n\n# TaxedMoney\ntm = TaxedMoney(net=Money(100, 'USD'), gross=Money(123, 'USD'))\nprint(tm)","lang":"python","description":"Basic usage of Price, PriceRange, and TaxedMoney classes."},"warnings":[{"fix":"Always specify currency, e.g., Price(currency='USD', net=..., gross=...).","message":"Currency is required on Price and Money. If you omit currency, you'll get a TypeError.","severity":"gotcha","affected_versions":"all"},{"fix":"Use the named tuple interface: price = Price(currency='USD', net=10, gross=12); price.net works, but price.net = 5 raises AttributeError.","message":"In version 0.5, Price and PriceRange became named tuples. Accessing attributes like .currency still works, but they are immutable.","severity":"breaking","affected_versions":">=0.5"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Provide currency: Price(currency='USD', net=Money(10, 'USD'), gross=Money(12, 'USD')).","cause":"Creating a Price or Money without specifying the currency argument (it is positional, often incorrectly omitted).","error":"TypeError: __init__() missing 1 required positional argument: 'currency'"},{"fix":"Use Price.net or Price.gross to get the Money object, then .amount on that Money: price.net.amount","cause":"Confusion with other libraries; Price does not have an 'amount' attribute. Use Price.net or Price.gross.","error":"AttributeError: 'Price' object has no attribute 'amount'"},{"fix":"Use 'from prices.discounts import FixedDiscount' instead of 'from prices import Discount'.","cause":"Incorrect import path for discount classes; they are in a submodule.","error":"ImportError: cannot import name 'Discount'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}