Skip to content

Instantly share code, notes, and snippets.

@gamingrobot
Created February 11, 2013 16:52
Show Gist options
  • Save gamingrobot/4755675 to your computer and use it in GitHub Desktop.
Save gamingrobot/4755675 to your computer and use it in GitHub Desktop.
Get calling class
def _getName(self):
retmod = "Module"
frame, module, line, function, context, index = inspect.stack()[2]
try:
self_argument = frame.f_code.co_varnames[0] # this should be self
instance = frame.f_locals[self_argument]
retmod = instance.__class__.__name__
except IndexError:
retmod = inspect.getmodulename(module)
return retmod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment