getting the function name
beliavsky at aol.com
beliavsky at aol.com
Fri Sep 17 13:27:39 EDT 2004
Is there a way in Python to print the name of the function one is
currently in?
The code
def foo():
debug = True
if (debug):
print "entered",__name__
x = foo()
outputs "entered __main__"
I want to print "entered foo". Of course I could just hard-code the
string "foo" in a print statement, but I don't want to have the
function name written in more than one place.
More information about the Python-list
mailing list