countries-dictionary 3.0.3__tar.gz → 3.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of countries-dictionary might be problematic. Click here for more details.
- {countries_dictionary-3.0.3 → countries_dictionary-3.1.1}/PKG-INFO +159 -4
- countries_dictionary-3.1.1/README.md +191 -0
- {countries_dictionary-3.0.3 → countries_dictionary-3.1.1}/countries_dictionary.egg-info/PKG-INFO +159 -4
- {countries_dictionary-3.0.3 → countries_dictionary-3.1.1}/pyproject.toml +2 -2
- countries_dictionary-3.0.3/README.md +0 -36
- {countries_dictionary-3.0.3 → countries_dictionary-3.1.1}/LICENCE +0 -0
- {countries_dictionary-3.0.3 → countries_dictionary-3.1.1}/countries_dictionary/__init__.py +0 -0
- {countries_dictionary-3.0.3 → countries_dictionary-3.1.1}/countries_dictionary/iso_finder.py +0 -0
- {countries_dictionary-3.0.3 → countries_dictionary-3.1.1}/countries_dictionary/quick_functions.py +0 -0
- {countries_dictionary-3.0.3 → countries_dictionary-3.1.1}/countries_dictionary/russia.py +0 -0
- {countries_dictionary-3.0.3 → countries_dictionary-3.1.1}/countries_dictionary/united_states.py +0 -0
- {countries_dictionary-3.0.3 → countries_dictionary-3.1.1}/countries_dictionary/vietnam.py +0 -0
- {countries_dictionary-3.0.3 → countries_dictionary-3.1.1}/countries_dictionary.egg-info/SOURCES.txt +0 -0
- {countries_dictionary-3.0.3 → countries_dictionary-3.1.1}/countries_dictionary.egg-info/dependency_links.txt +0 -0
- {countries_dictionary-3.0.3 → countries_dictionary-3.1.1}/countries_dictionary.egg-info/top_level.txt +0 -0
- {countries_dictionary-3.0.3 → countries_dictionary-3.1.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: countries_dictionary
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.1.1
|
|
4
4
|
Summary: Provides a dictionary contains all members and observer states of the United Nations and information about them
|
|
5
5
|
Author-email: Ngô Trần Quang Thiện <quangthienngotran@gmail.com>
|
|
6
6
|
License: GNU GENERAL PUBLIC LICENSE
|
|
@@ -679,7 +679,7 @@ License: GNU GENERAL PUBLIC LICENSE
|
|
|
679
679
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
|
680
680
|
Project-URL: Homepage, https://github.com/ThienFakeVN/countries_dictionary/
|
|
681
681
|
Project-URL: Repository, https://github.com/ThienFakeVN/countries_dictionary/
|
|
682
|
-
Keywords: countries,dictionary,united nations,states,russia,vietnam
|
|
682
|
+
Keywords: countries,dictionary,united nations,states,russia,united states,vietnam,iso
|
|
683
683
|
Requires-Python: >=3.7
|
|
684
684
|
Description-Content-Type: text/markdown
|
|
685
685
|
License-File: LICENCE
|
|
@@ -716,8 +716,163 @@ Countries Dictionary provides:
|
|
|
716
716
|
- Postal code
|
|
717
717
|
- Some functions which you might find helpful
|
|
718
718
|
|
|
719
|
-
Before using, it is recommended to see the code on [GitHub](https://github.com/ThienFakeVN/countries_dictionary/) to understand how it works
|
|
720
|
-
|
|
721
719
|
I created this module as an offline source of countries' information which is easy to access and use by coders.
|
|
722
720
|
|
|
723
721
|
See [CHANGELOG.md](https://github.com/ThienFakeVN/countries_dictionary/blob/main/CHANGELOG.md) for changes of releases.
|
|
722
|
+
|
|
723
|
+
Before using, it is recommended to see the code on [GitHub](https://github.com/ThienFakeVN/countries_dictionary/) or the below section to understand how the module works and how you can use it
|
|
724
|
+
|
|
725
|
+
## Codes
|
|
726
|
+
### Main Countries Dictionary
|
|
727
|
+
#### Structure
|
|
728
|
+
The Countries Dictionary has a structure like this:
|
|
729
|
+
```python
|
|
730
|
+
COUNTRIES = {
|
|
731
|
+
"Afghanistan": {
|
|
732
|
+
"formal name": "Islamic Emirate of Afghanistan",
|
|
733
|
+
"continents": ["Asia"],
|
|
734
|
+
"area": 652864.0,
|
|
735
|
+
"land area": 652230.0,
|
|
736
|
+
"population": 42045000,
|
|
737
|
+
"official languages": ["Dari", "Pashto"],
|
|
738
|
+
"nominal GDP": 16417000000,
|
|
739
|
+
"HDI": 0.496,
|
|
740
|
+
"ISO 3166-1": {"alpha-2": "AF", "alpha-3": "AFG", "numeric": "004"},
|
|
741
|
+
},
|
|
742
|
+
# ...
|
|
743
|
+
}
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
#### Usage example
|
|
747
|
+
```python
|
|
748
|
+
from countries_dictionary import COUNTRIES # Remember to import the module!
|
|
749
|
+
|
|
750
|
+
# Prints the formal name of the country
|
|
751
|
+
print(COUNTRIES["Vietnam"]["formal name"])
|
|
752
|
+
|
|
753
|
+
# Compares the population of two countries
|
|
754
|
+
print(COUNTRIES["North Korea"]["population"] > COUNTRIES["South Korea"]["population"])
|
|
755
|
+
print(COUNTRIES["North Korea"]["population"] == COUNTRIES["South Korea"]["population"])
|
|
756
|
+
print(COUNTRIES["North Korea"]["population"] < COUNTRIES["South Korea"]["population"])
|
|
757
|
+
|
|
758
|
+
# Creates the list of all countries
|
|
759
|
+
list_of_countries = list(COUNTRIES.keys())
|
|
760
|
+
print(list_of_countries)
|
|
761
|
+
```
|
|
762
|
+
|
|
763
|
+
### Russia dictionary
|
|
764
|
+
#### Structure
|
|
765
|
+
The Russia dictionary has a structure like this:
|
|
766
|
+
```python
|
|
767
|
+
RUSSIA = {
|
|
768
|
+
"Adygea": {
|
|
769
|
+
"federal district": "Southern",
|
|
770
|
+
"economic region": "North Caucasus",
|
|
771
|
+
"capital/administrative centre": "Maykop",
|
|
772
|
+
"area": 7792.0,
|
|
773
|
+
"population": 501038},
|
|
774
|
+
# ...
|
|
775
|
+
}
|
|
776
|
+
```
|
|
777
|
+
|
|
778
|
+
#### Usage example
|
|
779
|
+
```python
|
|
780
|
+
from countries_dictionary.russia import RUSSIA # Remember to import the module
|
|
781
|
+
|
|
782
|
+
# Prints the administrative centre of a krai
|
|
783
|
+
print(RUSSIA["Primorsky Krai"]["capital/administrative centre"])
|
|
784
|
+
|
|
785
|
+
# Sees if the two federal subjects are in the same federal district
|
|
786
|
+
print(RUSSIA["Tuva"]["federal district"] == RUSSIA["Altai Republic"]["federal district"])
|
|
787
|
+
|
|
788
|
+
# Creates the list of all federal subjects
|
|
789
|
+
list_of_federal_subjects = list(RUSSIA.keys())
|
|
790
|
+
print(list_of_federal_subjects)
|
|
791
|
+
```
|
|
792
|
+
|
|
793
|
+
### United States dictionary
|
|
794
|
+
#### Structure
|
|
795
|
+
The United States dictionary has a structure like this:
|
|
796
|
+
```python
|
|
797
|
+
UNITED_STATES = {
|
|
798
|
+
"Alabama": {
|
|
799
|
+
"capital": "Montgomery",
|
|
800
|
+
"date of ratification/establishment/acquiring": "1819.12.14",
|
|
801
|
+
"area": 135767.0,
|
|
802
|
+
"population": 5024279,
|
|
803
|
+
"House Representatives": 7,
|
|
804
|
+
"postal code": "AL",
|
|
805
|
+
}
|
|
806
|
+
# ...
|
|
807
|
+
}
|
|
808
|
+
```
|
|
809
|
+
|
|
810
|
+
#### Usage example
|
|
811
|
+
```python
|
|
812
|
+
from countries_dictionary.united_states import UNITED_STATES # Remember to import the module...
|
|
813
|
+
|
|
814
|
+
# Prints the postal code of a state
|
|
815
|
+
print(UNITED_STATES["Ohio"]["postal code"])
|
|
816
|
+
|
|
817
|
+
# Compares the numbers of House Representatives of two states
|
|
818
|
+
print(UNITED_STATES["Oklahoma"]["House Representatives"] > UNITED_STATES["Connecticut"]["House Representatives"])
|
|
819
|
+
print(UNITED_STATES["Oklahoma"]["House Representatives"] == UNITED_STATES["Connecticut"]["House Representatives"])
|
|
820
|
+
print(UNITED_STATES["Oklahoma"]["House Representatives"] < UNITED_STATES["Connecticut"]["House Representatives"])
|
|
821
|
+
|
|
822
|
+
# Creates the list of all states
|
|
823
|
+
list_of_states = list(UNITED_STATES.keys())
|
|
824
|
+
print(list_of_states)
|
|
825
|
+
```
|
|
826
|
+
|
|
827
|
+
### Vietnam dictionary
|
|
828
|
+
#### Structure
|
|
829
|
+
The Vietnam dictionary has a structure like this:
|
|
830
|
+
```python
|
|
831
|
+
VIETNAM = {
|
|
832
|
+
"Hanoi": {
|
|
833
|
+
"region": "Red River Delta",
|
|
834
|
+
"administrative centre": "Hoàn Kiếm ward",
|
|
835
|
+
"area": 3359.84,
|
|
836
|
+
"population": 8807523},
|
|
837
|
+
# ...
|
|
838
|
+
}
|
|
839
|
+
```
|
|
840
|
+
|
|
841
|
+
#### Usage example
|
|
842
|
+
```python
|
|
843
|
+
from countries_dictionary.vietnam import VIETNAM # Of course...
|
|
844
|
+
|
|
845
|
+
# Prints the population of a province
|
|
846
|
+
print(VIETNAM["Ho Chi Minh City"]["population"])
|
|
847
|
+
|
|
848
|
+
# Sees if the two provinces are in the same region
|
|
849
|
+
print(VIETNAM["Nghệ An province"]["region"] == VIETNAM["Hà Tĩnh province"]["region"])
|
|
850
|
+
|
|
851
|
+
# Creates the list of all provinces
|
|
852
|
+
list_of_provinces = list(VIETNAM.keys())
|
|
853
|
+
print(list_of_provinces)
|
|
854
|
+
```
|
|
855
|
+
|
|
856
|
+
### Quick functions
|
|
857
|
+
There are many functions in this submodule.
|
|
858
|
+
```python
|
|
859
|
+
import countries_dictionary.quick_functions as qf # What have you expected?
|
|
860
|
+
|
|
861
|
+
# Converts the dictionary into JSON and creates/overwrites a JSON file which contains the converted dictionary
|
|
862
|
+
with open("countries_dictionary.json", "w") as f:
|
|
863
|
+
f.write(qf.json_dictionary(indent=4))
|
|
864
|
+
|
|
865
|
+
# Prints a ISO 3166-2 code of a country
|
|
866
|
+
iso = qf.countries_iso_3166_2()
|
|
867
|
+
print(iso["Russia"]["ISO 3166-2"])
|
|
868
|
+
```
|
|
869
|
+
|
|
870
|
+
### ISO finder
|
|
871
|
+
*ISO finder* is a module which provides a function which has the same name. *ISO finder* can find a country based on the provided ISO code. Note that it does not include US states' postal codes.
|
|
872
|
+
```python
|
|
873
|
+
from countries_dictionary.iso_finder import iso_finder
|
|
874
|
+
|
|
875
|
+
print(iso_finder("VN"))
|
|
876
|
+
print(iso_finder("RUS"))
|
|
877
|
+
print(iso_finder("840"))
|
|
878
|
+
```
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# Countries Dictionary
|
|
2
|
+
Countries Dictionary provides:
|
|
3
|
+
- A dictionary contains all members and observer states of the United Nations and information about them:
|
|
4
|
+
- Formal name
|
|
5
|
+
- Continent(s) of the country's mainland
|
|
6
|
+
- Area and land area (in square kilometre)
|
|
7
|
+
- Population
|
|
8
|
+
- Official language(s)
|
|
9
|
+
- Nominal GDP (in dollar)
|
|
10
|
+
- Human Development Index
|
|
11
|
+
- ISO 3166-1 codes
|
|
12
|
+
- Another dictionary contains all federal subjects of the Russian Federation (including occupied zones in Ukraine) and information about them:
|
|
13
|
+
- Federal district
|
|
14
|
+
- Economic region
|
|
15
|
+
- Capital or administrative centre
|
|
16
|
+
- Area (in square kilometre)
|
|
17
|
+
- Population
|
|
18
|
+
- Another one contains all provinces and municipalities of the Socialist Republic of Vietnam and information about them:
|
|
19
|
+
- Region
|
|
20
|
+
- Administrative centre
|
|
21
|
+
- Area (in square kilometre)
|
|
22
|
+
- Population
|
|
23
|
+
- Another one contains all states, federal district and inhabited territories of the United Nations and information about them:
|
|
24
|
+
- Capital
|
|
25
|
+
- Date of ratification/establishment/acquiring
|
|
26
|
+
- Area (in square kilometre)
|
|
27
|
+
- Population
|
|
28
|
+
- House Representatives
|
|
29
|
+
- Postal code
|
|
30
|
+
- Some functions which you might find helpful
|
|
31
|
+
|
|
32
|
+
I created this module as an offline source of countries' information which is easy to access and use by coders.
|
|
33
|
+
|
|
34
|
+
See [CHANGELOG.md](https://github.com/ThienFakeVN/countries_dictionary/blob/main/CHANGELOG.md) for changes of releases.
|
|
35
|
+
|
|
36
|
+
Before using, it is recommended to see the code on [GitHub](https://github.com/ThienFakeVN/countries_dictionary/) or the below section to understand how the module works and how you can use it
|
|
37
|
+
|
|
38
|
+
## Codes
|
|
39
|
+
### Main Countries Dictionary
|
|
40
|
+
#### Structure
|
|
41
|
+
The Countries Dictionary has a structure like this:
|
|
42
|
+
```python
|
|
43
|
+
COUNTRIES = {
|
|
44
|
+
"Afghanistan": {
|
|
45
|
+
"formal name": "Islamic Emirate of Afghanistan",
|
|
46
|
+
"continents": ["Asia"],
|
|
47
|
+
"area": 652864.0,
|
|
48
|
+
"land area": 652230.0,
|
|
49
|
+
"population": 42045000,
|
|
50
|
+
"official languages": ["Dari", "Pashto"],
|
|
51
|
+
"nominal GDP": 16417000000,
|
|
52
|
+
"HDI": 0.496,
|
|
53
|
+
"ISO 3166-1": {"alpha-2": "AF", "alpha-3": "AFG", "numeric": "004"},
|
|
54
|
+
},
|
|
55
|
+
# ...
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
#### Usage example
|
|
60
|
+
```python
|
|
61
|
+
from countries_dictionary import COUNTRIES # Remember to import the module!
|
|
62
|
+
|
|
63
|
+
# Prints the formal name of the country
|
|
64
|
+
print(COUNTRIES["Vietnam"]["formal name"])
|
|
65
|
+
|
|
66
|
+
# Compares the population of two countries
|
|
67
|
+
print(COUNTRIES["North Korea"]["population"] > COUNTRIES["South Korea"]["population"])
|
|
68
|
+
print(COUNTRIES["North Korea"]["population"] == COUNTRIES["South Korea"]["population"])
|
|
69
|
+
print(COUNTRIES["North Korea"]["population"] < COUNTRIES["South Korea"]["population"])
|
|
70
|
+
|
|
71
|
+
# Creates the list of all countries
|
|
72
|
+
list_of_countries = list(COUNTRIES.keys())
|
|
73
|
+
print(list_of_countries)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Russia dictionary
|
|
77
|
+
#### Structure
|
|
78
|
+
The Russia dictionary has a structure like this:
|
|
79
|
+
```python
|
|
80
|
+
RUSSIA = {
|
|
81
|
+
"Adygea": {
|
|
82
|
+
"federal district": "Southern",
|
|
83
|
+
"economic region": "North Caucasus",
|
|
84
|
+
"capital/administrative centre": "Maykop",
|
|
85
|
+
"area": 7792.0,
|
|
86
|
+
"population": 501038},
|
|
87
|
+
# ...
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### Usage example
|
|
92
|
+
```python
|
|
93
|
+
from countries_dictionary.russia import RUSSIA # Remember to import the module
|
|
94
|
+
|
|
95
|
+
# Prints the administrative centre of a krai
|
|
96
|
+
print(RUSSIA["Primorsky Krai"]["capital/administrative centre"])
|
|
97
|
+
|
|
98
|
+
# Sees if the two federal subjects are in the same federal district
|
|
99
|
+
print(RUSSIA["Tuva"]["federal district"] == RUSSIA["Altai Republic"]["federal district"])
|
|
100
|
+
|
|
101
|
+
# Creates the list of all federal subjects
|
|
102
|
+
list_of_federal_subjects = list(RUSSIA.keys())
|
|
103
|
+
print(list_of_federal_subjects)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### United States dictionary
|
|
107
|
+
#### Structure
|
|
108
|
+
The United States dictionary has a structure like this:
|
|
109
|
+
```python
|
|
110
|
+
UNITED_STATES = {
|
|
111
|
+
"Alabama": {
|
|
112
|
+
"capital": "Montgomery",
|
|
113
|
+
"date of ratification/establishment/acquiring": "1819.12.14",
|
|
114
|
+
"area": 135767.0,
|
|
115
|
+
"population": 5024279,
|
|
116
|
+
"House Representatives": 7,
|
|
117
|
+
"postal code": "AL",
|
|
118
|
+
}
|
|
119
|
+
# ...
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
#### Usage example
|
|
124
|
+
```python
|
|
125
|
+
from countries_dictionary.united_states import UNITED_STATES # Remember to import the module...
|
|
126
|
+
|
|
127
|
+
# Prints the postal code of a state
|
|
128
|
+
print(UNITED_STATES["Ohio"]["postal code"])
|
|
129
|
+
|
|
130
|
+
# Compares the numbers of House Representatives of two states
|
|
131
|
+
print(UNITED_STATES["Oklahoma"]["House Representatives"] > UNITED_STATES["Connecticut"]["House Representatives"])
|
|
132
|
+
print(UNITED_STATES["Oklahoma"]["House Representatives"] == UNITED_STATES["Connecticut"]["House Representatives"])
|
|
133
|
+
print(UNITED_STATES["Oklahoma"]["House Representatives"] < UNITED_STATES["Connecticut"]["House Representatives"])
|
|
134
|
+
|
|
135
|
+
# Creates the list of all states
|
|
136
|
+
list_of_states = list(UNITED_STATES.keys())
|
|
137
|
+
print(list_of_states)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Vietnam dictionary
|
|
141
|
+
#### Structure
|
|
142
|
+
The Vietnam dictionary has a structure like this:
|
|
143
|
+
```python
|
|
144
|
+
VIETNAM = {
|
|
145
|
+
"Hanoi": {
|
|
146
|
+
"region": "Red River Delta",
|
|
147
|
+
"administrative centre": "Hoàn Kiếm ward",
|
|
148
|
+
"area": 3359.84,
|
|
149
|
+
"population": 8807523},
|
|
150
|
+
# ...
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
#### Usage example
|
|
155
|
+
```python
|
|
156
|
+
from countries_dictionary.vietnam import VIETNAM # Of course...
|
|
157
|
+
|
|
158
|
+
# Prints the population of a province
|
|
159
|
+
print(VIETNAM["Ho Chi Minh City"]["population"])
|
|
160
|
+
|
|
161
|
+
# Sees if the two provinces are in the same region
|
|
162
|
+
print(VIETNAM["Nghệ An province"]["region"] == VIETNAM["Hà Tĩnh province"]["region"])
|
|
163
|
+
|
|
164
|
+
# Creates the list of all provinces
|
|
165
|
+
list_of_provinces = list(VIETNAM.keys())
|
|
166
|
+
print(list_of_provinces)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Quick functions
|
|
170
|
+
There are many functions in this submodule.
|
|
171
|
+
```python
|
|
172
|
+
import countries_dictionary.quick_functions as qf # What have you expected?
|
|
173
|
+
|
|
174
|
+
# Converts the dictionary into JSON and creates/overwrites a JSON file which contains the converted dictionary
|
|
175
|
+
with open("countries_dictionary.json", "w") as f:
|
|
176
|
+
f.write(qf.json_dictionary(indent=4))
|
|
177
|
+
|
|
178
|
+
# Prints a ISO 3166-2 code of a country
|
|
179
|
+
iso = qf.countries_iso_3166_2()
|
|
180
|
+
print(iso["Russia"]["ISO 3166-2"])
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### ISO finder
|
|
184
|
+
*ISO finder* is a module which provides a function which has the same name. *ISO finder* can find a country based on the provided ISO code. Note that it does not include US states' postal codes.
|
|
185
|
+
```python
|
|
186
|
+
from countries_dictionary.iso_finder import iso_finder
|
|
187
|
+
|
|
188
|
+
print(iso_finder("VN"))
|
|
189
|
+
print(iso_finder("RUS"))
|
|
190
|
+
print(iso_finder("840"))
|
|
191
|
+
```
|
{countries_dictionary-3.0.3 → countries_dictionary-3.1.1}/countries_dictionary.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: countries_dictionary
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.1.1
|
|
4
4
|
Summary: Provides a dictionary contains all members and observer states of the United Nations and information about them
|
|
5
5
|
Author-email: Ngô Trần Quang Thiện <quangthienngotran@gmail.com>
|
|
6
6
|
License: GNU GENERAL PUBLIC LICENSE
|
|
@@ -679,7 +679,7 @@ License: GNU GENERAL PUBLIC LICENSE
|
|
|
679
679
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
|
680
680
|
Project-URL: Homepage, https://github.com/ThienFakeVN/countries_dictionary/
|
|
681
681
|
Project-URL: Repository, https://github.com/ThienFakeVN/countries_dictionary/
|
|
682
|
-
Keywords: countries,dictionary,united nations,states,russia,vietnam
|
|
682
|
+
Keywords: countries,dictionary,united nations,states,russia,united states,vietnam,iso
|
|
683
683
|
Requires-Python: >=3.7
|
|
684
684
|
Description-Content-Type: text/markdown
|
|
685
685
|
License-File: LICENCE
|
|
@@ -716,8 +716,163 @@ Countries Dictionary provides:
|
|
|
716
716
|
- Postal code
|
|
717
717
|
- Some functions which you might find helpful
|
|
718
718
|
|
|
719
|
-
Before using, it is recommended to see the code on [GitHub](https://github.com/ThienFakeVN/countries_dictionary/) to understand how it works
|
|
720
|
-
|
|
721
719
|
I created this module as an offline source of countries' information which is easy to access and use by coders.
|
|
722
720
|
|
|
723
721
|
See [CHANGELOG.md](https://github.com/ThienFakeVN/countries_dictionary/blob/main/CHANGELOG.md) for changes of releases.
|
|
722
|
+
|
|
723
|
+
Before using, it is recommended to see the code on [GitHub](https://github.com/ThienFakeVN/countries_dictionary/) or the below section to understand how the module works and how you can use it
|
|
724
|
+
|
|
725
|
+
## Codes
|
|
726
|
+
### Main Countries Dictionary
|
|
727
|
+
#### Structure
|
|
728
|
+
The Countries Dictionary has a structure like this:
|
|
729
|
+
```python
|
|
730
|
+
COUNTRIES = {
|
|
731
|
+
"Afghanistan": {
|
|
732
|
+
"formal name": "Islamic Emirate of Afghanistan",
|
|
733
|
+
"continents": ["Asia"],
|
|
734
|
+
"area": 652864.0,
|
|
735
|
+
"land area": 652230.0,
|
|
736
|
+
"population": 42045000,
|
|
737
|
+
"official languages": ["Dari", "Pashto"],
|
|
738
|
+
"nominal GDP": 16417000000,
|
|
739
|
+
"HDI": 0.496,
|
|
740
|
+
"ISO 3166-1": {"alpha-2": "AF", "alpha-3": "AFG", "numeric": "004"},
|
|
741
|
+
},
|
|
742
|
+
# ...
|
|
743
|
+
}
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
#### Usage example
|
|
747
|
+
```python
|
|
748
|
+
from countries_dictionary import COUNTRIES # Remember to import the module!
|
|
749
|
+
|
|
750
|
+
# Prints the formal name of the country
|
|
751
|
+
print(COUNTRIES["Vietnam"]["formal name"])
|
|
752
|
+
|
|
753
|
+
# Compares the population of two countries
|
|
754
|
+
print(COUNTRIES["North Korea"]["population"] > COUNTRIES["South Korea"]["population"])
|
|
755
|
+
print(COUNTRIES["North Korea"]["population"] == COUNTRIES["South Korea"]["population"])
|
|
756
|
+
print(COUNTRIES["North Korea"]["population"] < COUNTRIES["South Korea"]["population"])
|
|
757
|
+
|
|
758
|
+
# Creates the list of all countries
|
|
759
|
+
list_of_countries = list(COUNTRIES.keys())
|
|
760
|
+
print(list_of_countries)
|
|
761
|
+
```
|
|
762
|
+
|
|
763
|
+
### Russia dictionary
|
|
764
|
+
#### Structure
|
|
765
|
+
The Russia dictionary has a structure like this:
|
|
766
|
+
```python
|
|
767
|
+
RUSSIA = {
|
|
768
|
+
"Adygea": {
|
|
769
|
+
"federal district": "Southern",
|
|
770
|
+
"economic region": "North Caucasus",
|
|
771
|
+
"capital/administrative centre": "Maykop",
|
|
772
|
+
"area": 7792.0,
|
|
773
|
+
"population": 501038},
|
|
774
|
+
# ...
|
|
775
|
+
}
|
|
776
|
+
```
|
|
777
|
+
|
|
778
|
+
#### Usage example
|
|
779
|
+
```python
|
|
780
|
+
from countries_dictionary.russia import RUSSIA # Remember to import the module
|
|
781
|
+
|
|
782
|
+
# Prints the administrative centre of a krai
|
|
783
|
+
print(RUSSIA["Primorsky Krai"]["capital/administrative centre"])
|
|
784
|
+
|
|
785
|
+
# Sees if the two federal subjects are in the same federal district
|
|
786
|
+
print(RUSSIA["Tuva"]["federal district"] == RUSSIA["Altai Republic"]["federal district"])
|
|
787
|
+
|
|
788
|
+
# Creates the list of all federal subjects
|
|
789
|
+
list_of_federal_subjects = list(RUSSIA.keys())
|
|
790
|
+
print(list_of_federal_subjects)
|
|
791
|
+
```
|
|
792
|
+
|
|
793
|
+
### United States dictionary
|
|
794
|
+
#### Structure
|
|
795
|
+
The United States dictionary has a structure like this:
|
|
796
|
+
```python
|
|
797
|
+
UNITED_STATES = {
|
|
798
|
+
"Alabama": {
|
|
799
|
+
"capital": "Montgomery",
|
|
800
|
+
"date of ratification/establishment/acquiring": "1819.12.14",
|
|
801
|
+
"area": 135767.0,
|
|
802
|
+
"population": 5024279,
|
|
803
|
+
"House Representatives": 7,
|
|
804
|
+
"postal code": "AL",
|
|
805
|
+
}
|
|
806
|
+
# ...
|
|
807
|
+
}
|
|
808
|
+
```
|
|
809
|
+
|
|
810
|
+
#### Usage example
|
|
811
|
+
```python
|
|
812
|
+
from countries_dictionary.united_states import UNITED_STATES # Remember to import the module...
|
|
813
|
+
|
|
814
|
+
# Prints the postal code of a state
|
|
815
|
+
print(UNITED_STATES["Ohio"]["postal code"])
|
|
816
|
+
|
|
817
|
+
# Compares the numbers of House Representatives of two states
|
|
818
|
+
print(UNITED_STATES["Oklahoma"]["House Representatives"] > UNITED_STATES["Connecticut"]["House Representatives"])
|
|
819
|
+
print(UNITED_STATES["Oklahoma"]["House Representatives"] == UNITED_STATES["Connecticut"]["House Representatives"])
|
|
820
|
+
print(UNITED_STATES["Oklahoma"]["House Representatives"] < UNITED_STATES["Connecticut"]["House Representatives"])
|
|
821
|
+
|
|
822
|
+
# Creates the list of all states
|
|
823
|
+
list_of_states = list(UNITED_STATES.keys())
|
|
824
|
+
print(list_of_states)
|
|
825
|
+
```
|
|
826
|
+
|
|
827
|
+
### Vietnam dictionary
|
|
828
|
+
#### Structure
|
|
829
|
+
The Vietnam dictionary has a structure like this:
|
|
830
|
+
```python
|
|
831
|
+
VIETNAM = {
|
|
832
|
+
"Hanoi": {
|
|
833
|
+
"region": "Red River Delta",
|
|
834
|
+
"administrative centre": "Hoàn Kiếm ward",
|
|
835
|
+
"area": 3359.84,
|
|
836
|
+
"population": 8807523},
|
|
837
|
+
# ...
|
|
838
|
+
}
|
|
839
|
+
```
|
|
840
|
+
|
|
841
|
+
#### Usage example
|
|
842
|
+
```python
|
|
843
|
+
from countries_dictionary.vietnam import VIETNAM # Of course...
|
|
844
|
+
|
|
845
|
+
# Prints the population of a province
|
|
846
|
+
print(VIETNAM["Ho Chi Minh City"]["population"])
|
|
847
|
+
|
|
848
|
+
# Sees if the two provinces are in the same region
|
|
849
|
+
print(VIETNAM["Nghệ An province"]["region"] == VIETNAM["Hà Tĩnh province"]["region"])
|
|
850
|
+
|
|
851
|
+
# Creates the list of all provinces
|
|
852
|
+
list_of_provinces = list(VIETNAM.keys())
|
|
853
|
+
print(list_of_provinces)
|
|
854
|
+
```
|
|
855
|
+
|
|
856
|
+
### Quick functions
|
|
857
|
+
There are many functions in this submodule.
|
|
858
|
+
```python
|
|
859
|
+
import countries_dictionary.quick_functions as qf # What have you expected?
|
|
860
|
+
|
|
861
|
+
# Converts the dictionary into JSON and creates/overwrites a JSON file which contains the converted dictionary
|
|
862
|
+
with open("countries_dictionary.json", "w") as f:
|
|
863
|
+
f.write(qf.json_dictionary(indent=4))
|
|
864
|
+
|
|
865
|
+
# Prints a ISO 3166-2 code of a country
|
|
866
|
+
iso = qf.countries_iso_3166_2()
|
|
867
|
+
print(iso["Russia"]["ISO 3166-2"])
|
|
868
|
+
```
|
|
869
|
+
|
|
870
|
+
### ISO finder
|
|
871
|
+
*ISO finder* is a module which provides a function which has the same name. *ISO finder* can find a country based on the provided ISO code. Note that it does not include US states' postal codes.
|
|
872
|
+
```python
|
|
873
|
+
from countries_dictionary.iso_finder import iso_finder
|
|
874
|
+
|
|
875
|
+
print(iso_finder("VN"))
|
|
876
|
+
print(iso_finder("RUS"))
|
|
877
|
+
print(iso_finder("840"))
|
|
878
|
+
```
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "countries_dictionary"
|
|
7
|
-
version = "3.
|
|
7
|
+
version = "3.1.1"
|
|
8
8
|
description = "Provides a dictionary contains all members and observer states of the United Nations and information about them"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.7"
|
|
@@ -15,7 +15,7 @@ authors = [
|
|
|
15
15
|
|
|
16
16
|
license = { file = "LICENCE" }
|
|
17
17
|
|
|
18
|
-
keywords = ["countries", "dictionary", "united nations", "states", "russia", "vietnam"]
|
|
18
|
+
keywords = ["countries", "dictionary", "united nations", "states", "russia", "united states", "vietnam", "iso"]
|
|
19
19
|
|
|
20
20
|
[project.urls]
|
|
21
21
|
"Homepage" = "https://github.com/ThienFakeVN/countries_dictionary/"
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# Countries Dictionary
|
|
2
|
-
Countries Dictionary provides:
|
|
3
|
-
- A dictionary contains all members and observer states of the United Nations and information about them:
|
|
4
|
-
- Formal name
|
|
5
|
-
- Continent(s) of the country's mainland
|
|
6
|
-
- Area and land area (in square kilometre)
|
|
7
|
-
- Population
|
|
8
|
-
- Official language(s)
|
|
9
|
-
- Nominal GDP (in dollar)
|
|
10
|
-
- Human Development Index
|
|
11
|
-
- ISO 3166-1 codes
|
|
12
|
-
- Another dictionary contains all federal subjects of the Russian Federation (including occupied zones in Ukraine) and information about them:
|
|
13
|
-
- Federal district
|
|
14
|
-
- Economic region
|
|
15
|
-
- Capital or administrative centre
|
|
16
|
-
- Area (in square kilometre)
|
|
17
|
-
- Population
|
|
18
|
-
- Another one contains all provinces and municipalities of the Socialist Republic of Vietnam and information about them:
|
|
19
|
-
- Region
|
|
20
|
-
- Administrative centre
|
|
21
|
-
- Area (in square kilometre)
|
|
22
|
-
- Population
|
|
23
|
-
- Another one contains all states, federal district and inhabited territories of the United Nations and information about them:
|
|
24
|
-
- Capital
|
|
25
|
-
- Date of ratification/establishment/acquiring
|
|
26
|
-
- Area (in square kilometre)
|
|
27
|
-
- Population
|
|
28
|
-
- House Representatives
|
|
29
|
-
- Postal code
|
|
30
|
-
- Some functions which you might find helpful
|
|
31
|
-
|
|
32
|
-
Before using, it is recommended to see the code on [GitHub](https://github.com/ThienFakeVN/countries_dictionary/) to understand how it works
|
|
33
|
-
|
|
34
|
-
I created this module as an offline source of countries' information which is easy to access and use by coders.
|
|
35
|
-
|
|
36
|
-
See [CHANGELOG.md](https://github.com/ThienFakeVN/countries_dictionary/blob/main/CHANGELOG.md) for changes of releases.
|
|
File without changes
|
|
File without changes
|
{countries_dictionary-3.0.3 → countries_dictionary-3.1.1}/countries_dictionary/iso_finder.py
RENAMED
|
File without changes
|
{countries_dictionary-3.0.3 → countries_dictionary-3.1.1}/countries_dictionary/quick_functions.py
RENAMED
|
File without changes
|
|
File without changes
|
{countries_dictionary-3.0.3 → countries_dictionary-3.1.1}/countries_dictionary/united_states.py
RENAMED
|
File without changes
|
|
File without changes
|
{countries_dictionary-3.0.3 → countries_dictionary-3.1.1}/countries_dictionary.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|