Usage

teritorio has two iterable singletons: Countries and Currencies, and two dataclasses: Country and Currency, that represent a specific country or currency. Countries and Currencies are importable from teritorio.

Countries and Currencies, as they are singletons, can be instantiated more than once with negligible performance penalty.

Countries

class teritorio.main.Countries

An iterable of all countries

XYZ

The country with 3-letter code XYZ. The same country is accessible via square brackets Countries()[“XYZ”]

class teritorio.main.Country

A representation of a specific country.

english_name: str

The official name of the country in English

french_name: str

The official name of the country in French

alpha_2_code: str

The 2 letter code of the country

alpha_3_code: str

The 3 letter code of the country

numeric_code: int

The numeric code of the country

Example usage of the Countries class.

from teritorio import Countries

# list all countries
for country in Countries():
    print(country)

# get a specific country
countries = Countries()

# access the country as an attribute
print(countries.DEU)  # Country(english_name='Germany', french_name="Allemagne (l')", alpha_2_code='DE', alpha_3_code='DEU', numeric_code=276)
# access the country with square brackets
print(countries["DEU"])  # Country(english_name='Germany', french_name="Allemagne (l')", alpha_2_code='DE', alpha_3_code='DEU', numeric_code=276)

Currencies

class teritorio.main.Currencies

An iterable of all currencies

XYZ

The currency with 3-letter code XYZ. The same currency is accessible via square brackets Currencies()[“XYZ”]

class teritorio.main.Currency

A representation of a specific currency.

code: str

The 3 letter code of the currency

name: str

The name of the currency

entities: tuple[str, ...]

The list of entities (countries) that use this currency

numeric_code: int

The numeric code of the currency

minor_units: int | None

The number of decimal digits of this currency, if applicable

Example usage of the Currencies class.

from teritorio import Currencies

# list all currencies
for currency in Currencies():
    print(currency)

# get a specific currency
currencies = Currencies()

# access the currency as an attribute
print(currencies.GBP)  # Currency(code='GBP', name='Pound Sterling', entities=('GUERNSEY', 'ISLE OF MAN', 'JERSEY', 'UNITED KINGDOM OF GREAT BRITAIN AND NORTHERN IRELAND (THE)'), numeric_code=826, minor_units=2)
# access the currency with square brackets
print(currencies["GBP"])  # Currency(code='GBP', name='Pound Sterling', entities=('GUERNSEY', 'ISLE OF MAN', 'JERSEY', 'UNITED KINGDOM OF GREAT BRITAIN AND NORTHERN IRELAND (THE)'), numeric_code=826, minor_units=2)