Confused with methods
jfj
jfj at freemail.gr
Mon Feb 7 02:41:05 EST 2005
Diez B. Roggisch wrote:
> If things worked as you wanted it to, that would mean that passing a bound
> method as argument to a class and storing it there to an instance variable
> that would "eat up" the arguments - surely not the desired behaviour.
Could you please give an example of this ?
If you mean:
class A:
def f(x):
print x
class B:
pass
a=A()
B.f = a.f
b=B()
b.f() #surprise: it works!!
then that is equally "weird" as my case.
In fact is seems more appropriate to use a.f.im_func in this
case to "convert the bound method to an unbound one".
Maybe this happens more often though?
Thanks,
G.
More information about the Python-list
mailing list