Definitions of country and region names and codes as defined by ISO 3166-1 and the UN Statistics Division. The information in this module is current as of September 2015.
Given a country or region code as one of the following:
- String containing ISO 3166-1 alpha-2 code
- String containing ISO 3166-1 alpha-3 code
- String or integer containing ISO 3166-1 numeric code
- String containing DNS top-level domain alpha-2 code
- String or integer containing UN Statistics Division numeric region code
Returns the appropriate ISO 3166-1 or UN Statistics Division numeric code as an integer.
Note that some regions and other special items that are not defined by ISO 3166-1 or the UN Statistics Division are encoded as ISO 3166-1 user-assigned code elements.
Raises KeyError if the code is unrecognized.
Given a country or region code as a string or integer, returns the name for the country or region.
Raises KeyError if the country or region code is unrecognized.
Given a country or region code as a string or integer, returns a list of zero or more DNS top-level domains for that country or region.
Raises KeyError if the country or region code is unrecognized.
Given a country code as a string or integer, returns the ISO 3166-1 numeric code for the country.
Raises KeyError if the country code is unrecognized.
Given a country code as a string or integer, returns the name for the country.
Raises KeyError if the country code is unrecognized.
Given a country code as a string or integer, returns the ISO 3166-1 alpha-2 code for the country, or None if that is not possible.
Raises KeyError if the country code is unrecognized.
Given a country code as a string or integer, returns the ISO 3166-1 alpha-3 code for the country, or None if that is not possible.
Raises KeyError if the country code is unrecognized.
Given a country code as a string or integer, returns a list of zero or more DNS top-level domains for that country.
Raises KeyError if the country code is unrecognized.
Returns an iterator which yields all known ISO 3166-1 numeric country codes as integers, including user-assigned code elements in use.
Given a UN Statistics Division region code as a string or integer, returns the code as an integer.
Raises KeyError if the region code is unrecognized.
Given a region code as a string or integer, returns the name for the region.
Raises KeyError if the region code is unrecognized.
Given a region code as a string or integer, returns a list of zero or more DNS top-level domains for that region.
Raises KeyError if the region code is unrecognized.
Returns an iterator which yields all top-level UN Statistics Division numeric region codes as integers. This includes Africa, the Americas, Asia, Europe, Oceania, and Other.
Given the code for a containing region, returns an iterator which yields all second-level UN Statistics Division numeric region codes as integers.
Raises KeyError if the region code is unrecognized.
Given the code for a containing region, returns an iterator which yields as integers all ISO 3166-1 numeric country codes that are part of that region.