forked from fluentpython/example-code-2e
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcf.py
More file actions
executable file
·22 lines (18 loc) · 657 Bytes
/
cf.py
File metadata and controls
executable file
·22 lines (18 loc) · 657 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python3
import sys
import unicodedata
START, END = ord(' '), sys.maxunicode + 1 # <1>
def find(*query_words, start=START, end=END): # <2>
query = {w.upper() for w in query_words} # <3>
for code in range(start, end):
char = chr(code) # <4>
name = unicodedata.name(char, None) # <5>
if name and query.issubset(name.split()): # <6>
print(f'U+{code:04X}\t{char}\t{name}') # <7>
def main(words):
if words:
find(*words)
else:
print('Please provide words to find.')
if __name__ == '__main__':
main(sys.argv[1:])