Skip to main content

mundane

Pythonic Money class. Correct. Type-safe. Matches expectations.

Installation

pip install mundane

Required Python version: 3.12.

Usage

>>> from mundane import EUR, PLN, Money
>>> PLN(50) < PLN(100)
True
>>> PLN(50) < EUR(50)
TypeError: '<' not supported between money in 'PLN' and 'EUR'
>>> PLN(50) / 2
PLN('25')
>>> def do_something_with_money(money: Money):
...     print(money)
...
>>> do_something_with_money(PLN(25))
PLN 25
>>> do_something_with_money(EUR(50))
EUR 50

See tests/test_money.py for more examples.

Supported operations (a and b are money instances with matching currency):

  • a == b, a != b, a < b, a <= b, a > b, a >= b
  • +a, -a, abs(a)
  • a + b, a - b, 2 * a, a * 2, a / 2, a / b
  • round(a), round(a, 2), math.trunc(a), math.floor(a), math.ceil(a)
  • str(a), repr(a), hash(a)

Define your own currency

from mundane import TypedMoney

class BTC(TypedMoney):
    pass

print(BTC('0.0000000000000000000000000001'))
# BTC 0.0000000000000000000000000001

Metadata

Release files for mundane 0.1.1

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

Source distribution (sdist)

Source distribution for mundane 0.1.1
File Size Uploaded
mundane-0.1.1.tar.gz 12.4 kB Details

Built distribution (wheel)

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

Total release size: 19.6 kB

Release files / mundane-0.1.1.tar.gz

Download URL mundane-0.1.1.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0ef07832dbd50027f253210fd9c979fee6bd16c8c0cf3844307812e4bb20ec4f
BLAKE2b-256 checksum
How to use checksums
a0279c31c070d22e80d4e18fd3cec1f414036a6d4ca77f78167bdd25bb6d8b0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.24.1

Release files / mundane-0.1.1-py3-none-any.whl

Download URL mundane-0.1.1-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c95067f710ef0dceb8fbf12161b90214a5ba1abccfa4b72f840056616890f867
BLAKE2b-256 checksum
How to use checksums
effc21beba9aeba438864804d8ae8cf9a1a2beb852dac41ed1feb8ef707cf3e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.24.1

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

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