-
-
Save JeffPaine/3083347 to your computer and use it in GitHub Desktop.
# United States Postal Service (USPS) abbreviations. | |
abbreviations = [ | |
# https://en.wikipedia.org/wiki/List_of_states_and_territories_of_the_United_States#States. | |
"AK", "AL", "AR", "AZ", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "IA", | |
"ID", "IL", "IN", "KS", "KY", "LA", "MA", "MD", "ME", "MI", "MN", "MO", | |
"MS", "MT", "NC", "ND", "NE", "NH", "NJ", "NM", "NV", "NY", "OH", "OK", | |
"OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VA", "VT", "WA", "WI", | |
"WV", "WY", | |
# https://en.wikipedia.org/wiki/List_of_states_and_territories_of_the_United_States#Federal_district. | |
"DC", | |
# https://en.wikipedia.org/wiki/List_of_states_and_territories_of_the_United_States#Inhabited_territories. | |
"AS", "GU", "MP", "PR", "VI", | |
] | |
abbreviation_to_name = { | |
# https://en.wikipedia.org/wiki/List_of_states_and_territories_of_the_United_States#States. | |
"AK": "Alaska", | |
"AL": "Alabama", | |
"AR": "Arkansas", | |
"AZ": "Arizona", | |
"CA": "California", | |
"CO": "Colorado", | |
"CT": "Connecticut", | |
"DE": "Delaware", | |
"FL": "Florida", | |
"GA": "Georgia", | |
"HI": "Hawaii", | |
"IA": "Iowa", | |
"ID": "Idaho", | |
"IL": "Illinois", | |
"IN": "Indiana", | |
"KS": "Kansas", | |
"KY": "Kentucky", | |
"LA": "Louisiana", | |
"MA": "Massachusetts", | |
"MD": "Maryland", | |
"ME": "Maine", | |
"MI": "Michigan", | |
"MN": "Minnesota", | |
"MO": "Missouri", | |
"MS": "Mississippi", | |
"MT": "Montana", | |
"NC": "North Carolina", | |
"ND": "North Dakota", | |
"NE": "Nebraska", | |
"NH": "New Hampshire", | |
"NJ": "New Jersey", | |
"NM": "New Mexico", | |
"NV": "Nevada", | |
"NY": "New York", | |
"OH": "Ohio", | |
"OK": "Oklahoma", | |
"OR": "Oregon", | |
"PA": "Pennsylvania", | |
"RI": "Rhode Island", | |
"SC": "South Carolina", | |
"SD": "South Dakota", | |
"TN": "Tennessee", | |
"TX": "Texas", | |
"UT": "Utah", | |
"VA": "Virginia", | |
"VT": "Vermont", | |
"WA": "Washington", | |
"WI": "Wisconsin", | |
"WV": "West Virginia", | |
"WY": "Wyoming", | |
# https://en.wikipedia.org/wiki/List_of_states_and_territories_of_the_United_States#Federal_district. | |
"DC": "District of Columbia", | |
# https://en.wikipedia.org/wiki/List_of_states_and_territories_of_the_United_States#Inhabited_territories. | |
"AS": "American Samoa", | |
"GU": "Guam GU", | |
"MP": "Northern Mariana Islands", | |
"PR": "Puerto Rico PR", | |
"VI": "U.S. Virgin Islands", | |
} | |
# Example convenience transformations: | |
# | |
# ['AK', 'AL', ...] | |
abbreviations = sorted([abbr for abbr in abbreviation_to_name.keys()]) | |
# ['Alabama', 'Alaska', ...] | |
names = sorted([name for name in abbreviation_to_name.values()]) | |
# {'Alaska': 'AK', 'Alabama': 'AL', ...} | |
name_to_abbreviation = {v: k for k, v in abbreviation_to_name.items()} |
thanks
Small convenience great morale boost
states = (
('AK', 'Alaska'),
('AL', 'Alabama'),
('AR', 'Arkansas'),
('AZ', 'Arizona'),
('CA', 'California'),
('CO', 'Colorado'),
('CT', 'Connecticut'),
('DC', 'District of Columbia'),
('DE', 'Delaware'),
('FL', 'Florida'),
('GA', 'Georgia'),
('HI', 'Hawaii'),
('IA', 'Iowa'),
('ID', 'Idaho'),
('IL', 'Illinois'),
('IN', 'Indiana'),
('KS', 'Kansas'),
('KY', 'Kentucky'),
('LA', 'Louisiana'),
('MA', 'Massachusetts'),
('MD', 'Maryland'),
('ME', 'Maine'),
('MI', 'Michigan'),
('MN', 'Minnesota'),
('MO', 'Missouri'),
('MS', 'Mississippi'),
('MT', 'Montana'),
('NC', 'North Carolina'),
('ND', 'North Dakota'),
('NE', 'Nebraska'),
('NH', 'New Hampshire'),
('NJ', 'New Jersey'),
('NM', 'New Mexico'),
('NV', 'Nevada'),
('NY', 'New York'),
('OH', 'Ohio'),
('OK', 'Oklahoma'),
('OR', 'Oregon'),
('PA', 'Pennsylvania'),
('RI', 'Rhode Island'),
('SC', 'South Carolina'),
('SD', 'South Dakota'),
('TN', 'Tennessee'),
('TX', 'Texas'),
('UT', 'Utah'),
('VA', 'Virginia'),
('VT', 'Vermont'),
('WA', 'Washington'),
('WI', 'Wisconsin'),
('WV', 'West Virginia'),
('WY', 'Wyoming')
)
So useful!
Thank you! Big time saver!
Thank you very much! What a thoughtful thing for you to provide. Much appreciated.
Thank you!
Thanks.
beautiful thank you!!!
thank you!
Thank you!!
Saving us slow keyboarders and new-older coders more than two minutes each.