Re: how can I use a callable object as a method

2008-09-23 Thread Piotr Sobolewski
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

Re: how can I use a callable object as a method

2008-09-18 Thread Hrvoje Niksic
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

Re: how can I use a callable object as a method

2008-09-18 Thread Marco Wahl
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

how can I use a callable object as a method

2008-09-18 Thread Piotr Sobolewski
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