Is there a way to find the name of the method currently being executed?

Mark McEahern marklists at mceahern.com
Thu Sep 26 09:25:35 EDT 2002


import sys

def func1():
  print "my name is %s" % myname()

def myname():
  steps_back = 1
  return sys._getframe(steps_back).f_code.co_name

func1()




More information about the Python-list mailing list