A tiny Python library (version 2.0.4) that provides currency symbols by their ISO 4217 currency codes. It's actively maintained with a focus on simple lookups and no external dependencies, making it suitable for applications needing quick access to currency symbols.
pip install currency-symbolsVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to import the `CurrencySymbols` class and use its `get_symbol` method to retrieve the Unicode symbol for a given ISO 4217 currency code. It also shows the behavior for an unknown currency code.
Update your import statements to `from currency_symbols import CurrencySymbols` and access symbols via `CurrencySymbols.get_symbol('CODE')`.Use specialized libraries for formatting (`locale`, `Babel`) or conversion (`forex-python`) if you need more than just the raw currency symbol.
Refer to the Python-specific usage examples on the PyPI page or within the Python code itself, or carefully distinguish between Python and JavaScript examples in the GitHub README.
Add checks for `None` when calling `CurrencySymbols.get_symbol()` (e.g., `if symbol is not None: ... else: handle_missing_symbol()`).
Use an underscore in the import statement: `from currency_symbols import CurrencySymbols`
Verify the ISO 4217 currency code for accuracy. The library's `CurrencySymbols.get_symbol()` method expects a valid, supported three-letter code. If uncertain, you can check for the key's existence before attempting to retrieve it:
```python
from currency_symbols import CurrencySymbols
currency_code = 'XYZ' # Example of an unsupported code
try:
symbol = CurrencySymbols.get_symbol(currency_code)
print(f"Symbol for {currency_code}: {symbol}")
except KeyError:
print(f"Error: Currency code '{currency_code}' not found or supported.")
```Ensure your terminal, IDE, or environment is configured to use UTF-8 encoding and a font that includes a comprehensive set of Unicode glyphs for currency symbols (e.g., 'Consolas', 'DejaVu Sans Mono', 'Noto Color Emoji' for more exotic symbols). This often involves setting the locale or terminal font preferences.
No dependency data recorded yet.