Skip to content

Instantly share code, notes, and snippets.

@feltmax
Last active October 6, 2019 18:05
Show Gist options
  • Save feltmax/e59912a9f34e34015c050947d6169b80 to your computer and use it in GitHub Desktop.
Save feltmax/e59912a9f34e34015c050947d6169b80 to your computer and use it in GitHub Desktop.
get variable name list in python3
var_name = lambda val : [k for k, v in globals().items() if id(v) == id(val)]
a = 1
s = var_name(a)[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment