How to refer to the function object itself in the function per se?

Sullivan WxPyQtKinter sullivanz.pku at gmail.com
Sat Mar 11 23:35:14 CET 2006


I am sorry but you misunderstood my idea.
What I want is a generalized method to print out the function name, or
refer to the name of a function. If I use f.__name__, I think I should
just use print "f" to save my keyboard. What I expect is using a
method, or attribute, or another function to get the name of a
function.
Kay Schluehr 写道:

> Sullivan WxPyQtKinter wrote:
>
> > So how
> > could I refer to the function object per se, in the body of the
> > function itself?
>
> Just use the name.
> 
> def f():
>     print f.__name__
> 
> >>> f()
> f




More information about the Python-list mailing list