Skip to content

Commit 6f02985

Browse files
committed
Add phonetic.py.
1 parent b396aee commit 6f02985

2 files changed

Lines changed: 57 additions & 4 deletions

File tree

‎README.md‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,18 @@ A collection of simple Python scripts.
33

44
## Listings
55
### Python 3.3
6-
+ [ScrapeCountries.py](http://bamos.github.io/2013/05/03/scraping-tables-python/) -
7-
Scraping HTML tables with HTMLParser.
8-
Tests are located in `ScrapeCountriesTest.py`.
9-
+ [EvalExpr.py](http://bamos.github.io/2013/08/07/python-expression-evaluator/)
6+
+ [EvalExpr.py][eval-post].
107
A module to evaluate a mathematical expression using Python's AST.
118
Tests are located in `EvalExprTest.py`.
9+
+ [link-checker.py][link-checker-post].
10+
Builds upon linkchecker to hide warnings and to send a concise email
11+
if bad links are found.
12+
+ [ScrapeCountries.py][country-post].
13+
Scraping HTML tables with HTMLParser.
14+
Tests are located in `ScrapeCountriesTest.py`.
15+
+ `phonetic.py`.
16+
Obtain the NATO phonetic alphabet representation from short phrases.
17+
18+
[country-post]: http://bamos.github.io/2013/05/03/scraping-tables-python/
19+
[eval-post]: http://bamos.github.io/2013/08/07/python-expression-evaluator/
20+
[link-checker-post]: http://bamos.github.io/2014/02/06/link-checker-crontab/

‎python3.3/phonetic.py‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env python3.3
2+
#
3+
# phonetic.py
4+
# Obtain the NATO phonetic alphabet representation from short phrases.
5+
#
6+
# Brandon Amos <http://bamos.io>
7+
# 2014.02.14
8+
9+
import sys
10+
11+
phonetic_table = {
12+
'a': 'alpha',
13+
'b': 'bravo',
14+
'c': 'charlie',
15+
'd': 'delta',
16+
'e': 'echo',
17+
'f': 'foxtrot',
18+
'g': 'golf',
19+
'h': 'hotel',
20+
'i': 'india',
21+
'j': 'juliet',
22+
'k': 'kilo',
23+
'l': 'lima',
24+
'm': 'mike',
25+
'n': 'november',
26+
'o': 'oscar',
27+
'p': 'papa',
28+
'q': 'quebec',
29+
'r': 'romeo',
30+
's': 'sierra',
31+
't': 'tango',
32+
'u': 'uniform',
33+
'v': 'victor',
34+
'w': 'whiskey',
35+
'x': 'x-ray',
36+
'y': 'yankee',
37+
'z': 'zulu',
38+
}
39+
40+
for word in sys.argv[1:]:
41+
for char in word:
42+
if char not in phonetic_table: print(char.lower())
43+
else: print(char.lower() + ' - ' + phonetic_table[char])
44+
print()

0 commit comments

Comments
 (0)