API Reference¶
Base methods¶
All currency classes inherit the following methods from a base class:
- formatted(self) str ¶
Returns a string of the value in the currency format standard.
e.g.
>>> BRL(10).formatted() 'R$ 10,00'
Class methods¶
- sum(values: Sequence[Self]) Self ¶
Equivalent to builtin
sum
. Recieves a sequence of Currency instances, and returns its sum if all of them are from from the same class calling the method- Parameters:
values – Sequence of
Currency
values
e.g.
>>> values = [USD(x) for x in (5, 6, 1.5)] >>> USD.sum(values) <USD 12.50>
- mean(values: Sequence[Self]) Self ¶
Arithmetic mean of a sequence of Currency instances.
- Parameters:
values – Sequence of
Currency
values
e.g.
>>> values = [USD(x) for x in (10, 10, 7)] >>> USD.mean(values) <USD 9.00>
Available classes¶
- class BRL(value: int | float)¶
Class to represent Brazilian real
- class EUR(value: int | float)¶
Class to represent Euro
- class JPY(value: int | float)¶
Class to represent Japanese yen
- class USD(value: int | float)¶
Class to represent US dollar