Sullivan WxPyQtKinter wrote:
> So how
> could I refer to the function object per se, in the body of the
> function itself?
> 
> 
I don't believe you can easily get at the function object, but you can get 
at the code object which also has a name (which will be the same as the 
function's name unless you've been doing strange things):

>>> import inspect
>>> def f():
    print inspect.currentframe().f_code.co_name

    
>>> f()
f

For convenience you might want to put this inside a function:

>>> def myname():
    f = inspect.currentframe().f_back
    return f.f_code.co_name

>>> def f():
    print myname()

    
>>> f()
f

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to