Skip to content

Instantly share code, notes, and snippets.

@mijorus
Created July 8, 2022 13:04
Show Gist options
  • Save mijorus/e79f36c1e9d9e893ce6b67a19a034248 to your computer and use it in GitHub Desktop.
Save mijorus/e79f36c1e9d9e893ce6b67a19a034248 to your computer and use it in GitHub Desktop.
Python create dict from variables names
# Credit: https://stackoverflow.com/questions/39818733/create-dictionary-where-keys-are-variable-names
def create_dict(*args: str):
return dict({i:eval(i) for i in args})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment