Function creation (what happened?)
Viktor
alefnula at gmail.com
Fri May 9 09:02:01 EDT 2008
This completely slipped of my mind... :)
I'm trying to change the:
http://wordaligned.org/svn/etc/echo/echo.py
So if the function is method it prints ClassName.MethodName instead of
MethodName(self|klass|cls=<... ClassName>).
But it turned out that in the decorator, the wrapped function is
always just a TypeFunction (I cannot find out if the function is
method, classmethod, staticmethod or just a plain function - tried
with inspect also)... And what is most interesting, when I do:
def w(fn):
print 'fn:', id(fn)
return fn
class A:
@w
def __init__(self): pass
print 'A.__init__:', id(A.__init__)
It turns out that the function I receive in the wrapper (even when I
return the same function) is not the function which will finally be
attached to the class...
Is there a way to find out in the decorator "what will the decorated
function be"?
More information about the Python-list
mailing list