Skip to content

Instantly share code, notes, and snippets.

@raeq
Created August 2, 2020 20:16
Show Gist options
  • Save raeq/a417bbd8a24ac38ecc427a9dcafe62d3 to your computer and use it in GitHub Desktop.
Save raeq/a417bbd8a24ac38ecc427a9dcafe62d3 to your computer and use it in GitHub Desktop.
Dictionary Comprehension
asci_uppercase: dict = {i: chr(+i) for i in range(65, 91, 1)}
digits: dict = {i: chr(+i) for i in range(48, 58, 1)}
asci_lowercase: dict = {i: chr(+i) for i in range(97, 123, 1)}
asci_punctuation: dict = {i: chr(+i) for i in range(32, 48, 1)}
asci_punctuation.update({i: chr(+i) for i in range(123, 127, 1)})
asci_punctuation.update({i: chr(+i) for i in range(91, 97, 1)})
asci_punctuation.update({i: chr(+i) for i in range(58, 65, 1)})
asci_extended: dict = {i: chr(+i) for i in range(128, 255, 1)}
asci_system: dict = {i: hex(i) for i in range(0, 32, 1)}
ascii_chars: dict = {}
ascii_chars.update({"asci_punctuation": asci_punctuation})
ascii_chars.update({"asci_lowercase": asci_lowercase})
ascii_chars.update({"asci_uppercase": asci_uppercase})
ascii_chars.update({"digits": digits})
ascii_chars.update({"asci_extended": asci_extended})
ascii_chars.update({"asci_system": asci_system})
print(ascii_chars)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment