Skip to content

Commit

Permalink
add note on symbols to currency docs (#2023)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgsavage authored Jun 22, 2024
1 parent 9014d14 commit 62046f0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/advanced/currencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,16 @@ currency on its own dimension, and then implement transformations::
More sophisticated formulas, e.g. dealing with flat fees and thresholds, can be
implemented with arbitrary python code by programmatically defining a context (see
:ref:`contexts`).

Currency Symbols
----------------

Many common currency symbols are not supported by the pint parser. A preprocessor can be used as a workaround:

.. doctest::

>>> import pint
>>> ureg = pint.UnitRegistry(preprocessors = [lambda s: s.replace("", "EUR")])
>>> ureg.define("euro = [currency] = € = EUR")
>>> print(ureg.Quantity("1 €"))
1 euro

0 comments on commit 62046f0

Please sign in to comment.