Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
A python library to convert currency, prettify price and get various currency info
A simple currency module to:
.. code:: bash
$ pip install nh-currency
.. code:: python
import currency
Get currency name ^^^^^^^^^^^^^^^^^
.. code:: python
currency.name('USD')
currency.name('USD', plural=True)
.. code:: python
'US Dollar'
'US dollars'
Symbol ^^^^^^
.. code:: python
currency.symbol('CAD')
currency.symbol('CAD', native=False)
currency.symbol('NOK')
currency.symbol('NOK', native=False)
.. code:: python
'$'
'CA$'
'kr'
'Nkr'
Number of decimal digits ^^^^^^^^^^^^^^^^^^^^^^^^
.. code:: python
currency.decimals('USD')
currency.decimals('JPY')
.. code:: python
2
0
Round to the maximum decimal digits ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code:: python
currency.rounding(100.115735, 'USD')
currency.rounding(2253.12309, 'ISK')
.. code:: python
100.12
2253
Currency increment used for rounding ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code:: python
currency.roundto('USD')
currency.roundto('CHF')
.. code:: python
0
0.05
Format currency ^^^^^^^^^^^^^^^
.. code:: python
currency.pretty(10050000.2394, 'USD')
currency.pretty(10050000.2394, 'USD', trim=True)
currency.pretty(10050000.2394, 'USD', abbrev=False)
.. code:: python
'$10,050,000.2394'
'$10,050,000.24'
'10,050,000.2394 USD'
Convert to other currency ^^^^^^^^^^^^^^^^^^^^^^^^^
.. code:: python
currency.convert('USD', 'EUR')
currency.convert('USD', 'EUR', 2)
currency.convert('JPY', 'AUD', 100)
.. code:: python
0.815797
1.631594
1.1759
Currency info ^^^^^^^^^^^^^
.. code:: python
currency.info('USD')
.. code:: python
# Output has been formatted for representation purpose
{
'symbol': '$',
'name': 'US Dollar',
'symbol_native': '$',
'decimal_digits': 2,
'rounding': 0,
'code': 'USD',
'name_plural': 'US dollars'
}
.. code:: bash
$ cd .../py-currency
$ python -m unittest
coinify <https://github.com/StorePilot/coinify>
__
FAQs
A python library to convert currency, prettify price and get various currency info
We found that nh-currency demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.