Created
June 15, 2017 22:03
-
-
Save rbanffy/8b7b1da4fd8dd3cc91bcdd24515527df to your computer and use it in GitHub Desktop.
Show unicode identifier ranges for Python 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Show unicode identifier ranges." | |
in_identifier_range = False | |
for codepoint in range(int('10ffff', 16)): # Last mapped codepoint is U+10FFFF | |
if chr(codepoint).isidentifier() and not in_identifier_range: | |
# We are transitioning into a range. | |
in_identifier_range = True | |
start = codepoint | |
elif not chr(codepoint).isidentifier() and in_identifier_range: | |
# We are transitioning out of a range. | |
in_identifier_range = False | |
print('{}-{}: {}'.format( | |
hex(start), | |
hex(codepoint - 1), | |
''.join((chr(i) for i in range(start, codepoint)))[:60])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment