Dynamic class methods misunderstanding
Bill Mill
bill.mill at gmail.com
Fri Jan 28 10:20:30 EST 2005
Hello all,
I have a misunderstanding about dynamic class methods. I don't expect
this behavior:
In [2]: class test:
...: def __init__(self, method):
...: self.method = method
...: self.method()
...:
In [3]: def m(self): print self
...:
In [4]: test(m)
---------------------------------------------------------------------------
exceptions.TypeError Traceback (most recent call
last)
/cygdrive/c/Documents and Settings/Wmill/<console>
/cygdrive/c/Documents and Settings/Wmill/<console> in __init__(self, method)
TypeError: m() takes exactly 1 argument (0 given)
-----------------------------------------------------------------------------
Why doesn't m get the implicit self parameter in the self.method()
call? How would I make it a proper member of the class, so that a
self.method() call would work with the above "m" function?
Peace
Bill Mill
bill.mill at gmail.com
More information about the Python-list
mailing list