Skip to content

Instantly share code, notes, and snippets.

@rbanffy
Created June 15, 2017 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbanffy/8b7b1da4fd8dd3cc91bcdd24515527df to your computer and use it in GitHub Desktop.
Save rbanffy/8b7b1da4fd8dd3cc91bcdd24515527df to your computer and use it in GitHub Desktop.
Show unicode identifier ranges for Python 3
"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