File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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/
Original file line number Diff line number Diff line change 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 ()
You can’t perform that action at this time.
0 commit comments