A no-frill currency formatting library.
Project description
Format Numbers as Currencies
A no-frill currency formatting library.
Table of Contents
Installation
pip install format-currency
Usage
from format_currency import format_currency
# format currency by country code, using the selected country's local monetary number formatting
formatted = format_currency(1234567.89, 'US') # returns $ 1,234,567.89
formatted = format_currency(1234567.89, 'ID') # returns Rp 1.234.567,89
# format currency by currency code
formatted = format_currency(1234567.89, currency_code='USD') # returns $ 1,234,567.89
formatted = format_currency(1234567.89, currency_code='IDR') # returns Rp 1.234.567,89
# smart formatting
formatted = format_currency(value, country_code='CN', smart_number_formatting=True) # returns ¥ 123.46 万
# format currency by country code, respecting global locale settings
import locale
locale.setlocale(locale.LC_ALL, '')
formatted = format_currency(1234567.89, 'US', use_current_locale=True) # returns $ 1,234,567.89
formatted = format_currency(1234567.89, 'ID', use_current_locale=True) # returns Rp 1,234,567.89
Testing
Install dependencies:
python -m pip install --upgrade pip build hatch
Run the test runner:
./test_runner.sh
License
format-currency is distributed under the terms of the MIT license.
References
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
format_currency-0.0.10.tar.gz
(169.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file format_currency-0.0.10.tar.gz.
File metadata
- Download URL: format_currency-0.0.10.tar.gz
- Upload date:
- Size: 169.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15f01e5aaecf7c636815911cf0cbab0b117c8a6bd992d61a666f5e038cce32d9
|
|
| MD5 |
f90dbda70792d7b12fa12762fbc0ddd9
|
|
| BLAKE2b-256 |
3d18ee5527f52565bd79f3111e7fac7fbfe384f5b9bf909431814c2dc0457815
|
File details
Details for the file format_currency-0.0.10-py3-none-any.whl.
File metadata
- Download URL: format_currency-0.0.10-py3-none-any.whl
- Upload date:
- Size: 167.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eedecf0b2c4d21b2435eff3eed95658160d0602c444f921dd22ce4bfab7735c7
|
|
| MD5 |
87c137348a5d10a4fc9f00acb2b02412
|
|
| BLAKE2b-256 |
94cb788941330c524422c87583121b0d589636a982fad0685f9f3b7c7588c2f4
|