Is there a way to find the name of the method currently being executed?
Craeg K Strong
cstrong at arielpartners.com
Wed Sep 25 23:02:40 EDT 2002
Hello:
class a:
def func1(self):
print "func1 being called"
def func2(self):
print "func2 being called"
In the code sample above, I would like to replace the "func1"
and "func2" strings with constants so the same code could
be copied verbatim into multiple functions and do the right
thing.
Is there a way to do this in Python? For example, maybe you could
get your hands on the call stack and print out stack[0].__name__
or something....
Thanks in advance,
--Craeg
BTW, I could not find this in the python.org FAQ....
More information about the Python-list
mailing list