'self' disappearing
Daniel Nouri
daniel.nouri at con-fuse.org
Fri Jul 4 17:58:51 EDT 2003
Answering my own question:
Only a class attribute that is of FunctionType will be automatically
converted into a bound method by the Python interpreter. If I wanted more
control, I would have to do it through metaclasses.
However, my (working) approach now is to return a function instead of a
class instance, using this simple closure:
def make_funwrapper(fun):
def funwrapper(*args, **kwds):
print 'Calling', fun.__name__
fun(*args, **kwds)
return funwrapper
Note that this requires Python 2.2 or 'from __future__ import
nested_scopes' because I'm using 'fun' in the nested function.
More information about the Python-list
mailing list