Skip to main content

This project provides lists of various ISO standards (e.g. country, language, language scripts, and currency names) in one place

Project description

isocodes

isocodes provides you access to lists of various ISO standards (e.g. country, language, language scripts, and currency names).

The data is coming from https://salsa.debian.org/iso-codes-team/iso-codes, many thanks to them.

Installation

pip install isocodes

Usage

Countries (ISO 3166)

Get method

You can acces one country by using the method get with the parameters being the json keys of the .json files in the share/iso-codes/json folder

Example

>>> from isocodes import countries
>>> countries.get(name="Germany")
{'alpha_2': 'DE', 'alpha_3': 'DEU', 'flag': '🇩🇪', 'name': 'Germany', 'numeric': '276', 'official_name': 'Federal Republic of Germany'}

Items property

You can get a json parsed list from the .json files in the share/iso-codes/json folder with the items property.

That list contains each countries in the form of the dictionary that you can get with the method get.

Example

>>> from isocodes import countries
>>> for country in countries.items:
...     print(country)
...
{'alpha_2': 'AW', 'alpha_3': 'ABW', 'flag': '🇦🇼', 'name': 'Aruba', 'numeric': '533'}
{'alpha_2': 'AF', 'alpha_3': 'AFG', 'flag': '🇦🇫', 'name': 'Afghanistan', 'numeric': '004', 'official_name': 'Islamic Republic of Afghanistan'}
{'alpha_2': 'AO', 'alpha_3': 'AGO', 'flag': '🇦🇴', 'name': 'Angola', 'numeric': '024', 'official_name': 'Republic of Angola'}
{'alpha_2': 'AI', 'alpha_3': 'AIA', 'flag': '🇦🇮', 'name': 'Anguilla', 'numeric': '660'}
{'alpha_2': 'AX', 'alpha_3': 'ALA', 'flag': '🇦🇽', 'name': 'Åland Islands', 'numeric': '248'}

by_xxx property

You can get a list with sorted data by one of the property with the by_xxx property, xxx being one of the data key (alpha_2, name, numeric, etc.).

Example

>>> countries.by_numeric[0]
('004', {'alpha_2': 'AF', 'alpha_3': 'AFG', 'flag': '🇦🇫', 'name': 'Afghanistan', 'numeric': '004', 'official_name': 'Islamic Republic of Afghanistan'})

Languages (ISO 639-2)

Same as countries but you replace countries by languages

Currencies (ISO 4217)

Same as countries but you replace countries by currencies

Countries and Subdivisions (ISO 3166-2)

Same as countries but you replace countries by subdivisions_countries

Former countries (ISO 3166-3)

Same as countries but you replace countries by former_countries

Extended languages (ISO 639-3)

Same as countries but you replace countries by extendend_languages

Language families (ISO 639-5)

Same as countries but you replace countries by language_families

Script names (ISO 15924)

Same as countries but you replace countries by script_names

Translations

Translations are included in this project with gettext support. The domain names are to be found on https://salsa.debian.org/iso-codes-team/iso-codes

Example

>>> import gettext
>>> import isocodes
>>> french = gettext.translation('iso_639-2', isocodes.LOCALES_DIR, languages=['fr'])
>>> french.install()
>>> _("French")
'français'

Develop

Don't forget to clone the submodules as well and execute update.sh to update the debian's iso-codes repo.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

isocodes-2024.2.2.tar.gz (6.8 MB view details)

Uploaded Source

Built Distribution

isocodes-2024.2.2-py2.py3-none-any.whl (13.8 MB view details)

Uploaded Python 2 Python 3

File details

Details for the file isocodes-2024.2.2.tar.gz.

File metadata

  • Download URL: isocodes-2024.2.2.tar.gz
  • Upload date:
  • Size: 6.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for isocodes-2024.2.2.tar.gz
Algorithm Hash digest
SHA256 50b747edb5f4e1e7bb740e972ec5062b9819fc1fd417c33ee6334436a3367f6a
MD5 e8f9257ce417c18ac4616a5800aae71e
BLAKE2b-256 fad644206b3de217a0f6c3e6e8136b995317eacdb4085cabfd03c441344bb3d4

See more details on using hashes here.

File details

Details for the file isocodes-2024.2.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for isocodes-2024.2.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fef39f47821dff04dd3a311d1f8ddcdabac3de37e048398697e71b68b879e15c
MD5 29513295241f0ebdff7c95ac0ee16476
BLAKE2b-256 30bb2a9548f94317c8cf2729652cdd5e165c4050bfe3aacfaec28d4e34685e50

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page