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
Piotr Sobolewski <[EMAIL PROTECTED]> writes:
> 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 conv
Piotr Sobolewski <[EMAIL PROTECTED]> writes:
> I would like to use a callable object as a method of a class. So, when I
> have such normal class:
>
> I want to change it to something like that:
>
> class add:
> def __call__(self, another_self):
> return another_self.version
Hello,
I would like to use a callable object as a method of a class. So, when I
have such normal class:
class f:
version = 17
def a(self):
return self.version
f1 = f()
print f1.a()
I want to change it to something like that:
class add:
def __call__(self