Skip to content

Instantly share code, notes, and snippets.

@hyoretsu
Created June 5, 2022 19:39
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 hyoretsu/25493880a7c981c0fd3447f0119bc7ec to your computer and use it in GitHub Desktop.
Save hyoretsu/25493880a7c981c0fd3447f0119bc7ec to your computer and use it in GitHub Desktop.
Various useful Python functions
import inspect
def get_var_name(var):
callers_local_vars = inspect.currentframe().f_back.f_locals.items()
return [var_name for var_name, var_val in callers_local_vars if var_val is var]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment