Re: substitution of a method by a callable object

2008-10-22 Thread netimen
On 23 окт, 00:26, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > netimen a écrit : > (snip) > > > OK, I have implemented Bruno Desthuilliers example. But there is > > another question: can I having a method determine if it is an instance > > of given class. So: > > As the name imply, a method is

Re: substitution of a method by a callable object

2008-10-22 Thread Bruno Desthuilliers
netimen a écrit : (snip) OK, I have implemented Bruno Desthuilliers example. But there is another question: can I having a method determine if it is an instance of given class. So: As the name imply, a method is usually, well, an instance of type 'method' !-) class Obj(object): (snip) cl

Re: substitution of a method by a callable object

2008-10-22 Thread netimen
On 23 окт, 00:34, Terry Reedy <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > On Oct 22, 12:13 pm, netimen <[EMAIL PROTECTED]> wrote: > > >> Can I substitute a method of a class by a callable object (not a > >> function)? I can very easy insert my function in a class as a method, > >> but an

Re: substitution of a method by a callable object

2008-10-22 Thread Terry Reedy
George Sakkis wrote: On Oct 22, 12:13 pm, netimen <[EMAIL PROTECTED]> wrote: Can I substitute a method of a class by a callable object (not a function)? I can very easy insert my function in a class as a method, but an object - can't. I have the following: class Foo(object): pass class O

Re: substitution of a method by a callable object

2008-10-22 Thread netimen
On 22 окт, 20:46, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > netimen a écrit : > > > Can I substitute a method of a class by a callable object (not a > > function)? I can very easy insert my function in a class as a method, > > but an object - can't. > > functions implement the descriptor pro

Re: substitution of a method by a callable object

2008-10-22 Thread Bruno Desthuilliers
netimen a écrit : Can I substitute a method of a class by a callable object (not a function)? I can very easy insert my function in a class as a method, but an object - can't. functions implement the descriptor protocol so when looked up as class attributes, the lookup invoke their __get__ met

Re: substitution of a method by a callable object

2008-10-22 Thread George Sakkis
On Oct 22, 12:13 pm, netimen <[EMAIL PROTECTED]> wrote: > Can I substitute a method of a class by a callable object (not a > function)? I can very easy insert my function in a class as a method, > but an object - can't. > > I have the following: > > class Foo(object): >     pass > > class Obj(obje

Re: substitution of a method by a callable object

2008-10-22 Thread Terry Reedy
netimen wrote: Can I substitute a method of a class by a callable object (not a function)? I can very easy insert my function in a class as a method, but an object - can't. Yes you can and did. class Foo(object): pass class Obj(object): def __call__(self, obj_self): print 'Ob

substitution of a method by a callable object

2008-10-22 Thread netimen
Can I substitute a method of a class by a callable object (not a function)? I can very easy insert my function in a class as a method, but an object - can't. I have the following: class Foo(object): pass class Obj(object): def __call__(self, obj_self): print 'Obj' def func(self)