A python library to convert currency, prettify price and get various currency info
Project description
A simple currency module to:
Retrive various info about currency
Format currency price
Convert between currencies
Requirements
python3
Internet connection (optional)
Installation
$ pip install nh-currency
Usage
import currency
Get currency name
currency.name('USD')
currency.name('USD', plural=True)
'US Dollar'
'US dollars'
Symbol
currency.symbol('CAD')
currency.symbol('CAD', native=False)
currency.symbol('NOK')
currency.symbol('NOK', native=False)
'$'
'CA$'
'kr'
'Nkr'
Number of decimal digits
currency.decimals('USD')
currency.decimals('JPY')
2
0
Round to the maximum decimal digits
currency.rounding(100.115735, 'USD')
currency.rounding(2253.12309, 'ISK')
100.12
2253
Currency increment used for rounding
currency.roundto('USD')
currency.roundto('CHF')
0
0.05
Format currency
currency.pretty(10050000.2394, 'USD')
currency.pretty(10050000.2394, 'USD', trim=True)
currency.pretty(10050000.2394, 'USD', abbrev=False)
'$10,050,000.2394'
'$10,050,000.24'
'10,050,000.2394 USD'
Convert to other currency
currency.convert('USD', 'EUR')
currency.convert('USD', 'EUR', 2)
currency.convert('JPY', 'AUD', 100)
0.815797
1.631594
1.1759
Currency info
currency.info('USD')
# Output has been formatted for representation purpose
{
'symbol': '$',
'name': 'US Dollar',
'symbol_native': '$',
'decimal_digits': 2,
'rounding': 0,
'code': 'USD',
'name_plural': 'US dollars'
}
Testing
$ cd .../py-currency
$ python -m unittest
Resources
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
nh-currency-1.0.1.tar.gz
(10.7 kB
view hashes)
Built Distribution
Close
Hashes for nh_currency-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6848d94e1023e9b112551a9067c56459fc294710c702c1fc0c89f1a0e17edaf4 |
|
MD5 | 35c32376d13c134bbfdaf4fbdd2a9ae0 |
|
BLAKE2b-256 | 3e85c10a5b8d423a2661807ce3a6cb1a0b480f0956409d4691f7aab83ecf93a4 |