how can I use a callable object as a method
NIE_DZIALA at gazeta.pl
Tue Sep 23 18:44:12 CEST 2008
Hrvoje Niksic wrote:
>> However, the second version does not work. I think I understand
>> why. That's because "a" inside f1 is not a function (but an object).
> An object that defines __call__ is perfectly usable as a function.
> Your problem is that it doesn't know how to convert itself to a
> method, so that f1.a() knows how to pass f1 as another_self to
> add.__call__. To do that, add needs to be a bit smarter:
A! Now it works, thanks a lot!
More information about the Python-list