A Python module to access general countries information including name, origin name, dial code, currency, capital, timezone, and current time.
Project description
countries-meta
A Python module to access general countries information including name, origin name, dial code, currency, capital, timezone, and current time.
Installation
pip install countries-meta
Usage
from countries_meta import Countries
countries = Countries()
# Get country by code
us = countries.get_by_code('US')
us = countries.get('US')
us = countries['US']
print(us.name) # United States
# Get country by name
germany = countries.get_by_name('Germany')
print(germany.capital) # Berlin
# Get country by origin name
fr = countries.get_by_origin_name('République française')
print(fr.dial_code) # +33
# Get country by dial code
canada = countries.get_by_dial_code('+1')
print(canada.name) # Canada
# Filter countries by currency code
usd_countries = countries.filter_by_currency_code('USD')
print([c.name for c in usd_countries])
# Filter countries by region
european_countries = countries.filter_by_region('Europe')
print([c.name for c in european_countries])
# Access timezone info and current time
print(us.timezone) # America/Washington
print(us.now) # Current local time
print(us.time_offset) # Offset in hours from UTC
# Convert to dict or JSON
print(us.to_dict())
print(us.to_json())
Classes
Country
-
Attributes:
code,name,origin_name,dial_code,currency_code,currency_symbol,capital,timezone -
Properties:
tzinfo:ZoneInfoobject for the timezonenow: current datetime in the country's timezonetime_offset: UTC offset in hours
-
Methods:
to_dict(*keys): return dict representationto_json(*keys): return JSON string
Countries
-
Iterable container of all countries
-
Methods to access countries:
get_by_code(code)get_by_name(name)get_by_origin_name(name)get_by_dial_code(dial_code)get_by_currency_code(currency_code)filter_by_currency_code(currency_code)filter_by_region(region)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file countries_meta-0.1.1.tar.gz.
File metadata
- Download URL: countries_meta-0.1.1.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
338b22975085cce75821c3eff1e46ef7b2817c46c1388be1ad6f8028ad098c36
|
|
| MD5 |
c989eb6a5fc1335043fd2a8e5db14e6f
|
|
| BLAKE2b-256 |
0284aa98585d1551fd57f38a79463e14498e4af6fc260a5f59bd49930460e02d
|
File details
Details for the file countries_meta-0.1.1-py3-none-any.whl.
File metadata
- Download URL: countries_meta-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c97300bbe94048a7f0f91999c350b625e59e8000aeacd635eabf9c6b2992af87
|
|
| MD5 |
a75285bb22ac85999aeab59da134ebea
|
|
| BLAKE2b-256 |
b909e87f80624cddd6b2b8dab9edc416762bd3891541b49f7e619ba1ab7746e1
|