Basic Usage

Library

The main exposed interface for the library is Country, and can be initialized for a country indicating explicitly what data we are using or implicitly.

Explicitly, we can use whatever data field included. For example, retrieve Spain using ISO-3361-1 Alpha3 code, using a3 as optional argument:

>>> from countrydata import Country
>>> country = Country(a3="ESP")
>>> country.data
{'codes': {'a2': 'ES', 'a3': 'ESP', 'num': 724, 'gec': 'SP'}}

Implicitly, countrydata tries to infer what field you are using. Let’s try to retrieve Spain using ISO-3361-1 Numeric3 code as positional argument:

>>> country = Country(724)
>>> country.data
{'codes': {'a2': 'ES', 'a3': 'ESP', 'num': 724, 'gec': 'SP'}}

Warning

Keep in mind that positional arguments countries initialization may currently initialize unexpected countries.

Command line client

Run countrydata --help or countrydata <command> --help to see documentation for all commands.

$ countrydata get-value numeric ESP
724

$ countrydata get-value "ISO-3361-1 Alpha2" 724
ES