Skip to content

Instantly share code, notes, and snippets.

@whalesalad
Created May 30, 2017 15:14
Show Gist options
  • Save whalesalad/cfc8bc116ec862423ed319edc18ebcf2 to your computer and use it in GitHub Desktop.
Save whalesalad/cfc8bc116ec862423ed319edc18ebcf2 to your computer and use it in GitHub Desktop.
def arange(start, end):
"""alphanumeric range, inclusive"""
return (chr(i) for i in range(ord(start), ord(end) + 1))
>>> arange('A', 'B')
<generator object arange.<locals>.<genexpr> at 0x1047bcbf8>
>>> list(arange('A', 'Z'))
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment