Re: Unexpected result when comparing method with variable

2005-04-04 Thread Michael Spencer
David Handy wrote: I had a program fail on me today because the following didn't work as I expected: class C: ... def f(self): ... pass ... c = C() m = c.f m is c.f False I would have expected that if I set a variable equal to a bound method, that variable, for all intents and purposes

Re: Unexpected result when comparing method with variable

2005-04-04 Thread David Handy
On Tue, Apr 05, 2005 at 03:38:09PM +1200, Tony Meyer wrote: > [David Handy] > > I had a program fail on me today because the following didn't > > work as I expected: > > > > >>> class C: > > ... def f(self): > > ... pass > > ... > > >>> c = C() > > >>> m = c.f > > >>> m is c.f > > Fal

Re: Unexpected result when comparing method with variable

2005-04-04 Thread Ron_Adam
On Mon, 4 Apr 2005 23:34:41 -0400, David Handy <[EMAIL PROTECTED]> wrote: I'm not sure if this is the best way. But it might work. for method, params in deferred: method(*params) try: if method.im_func is c.f.im_func: # handle a special case except: if

Re: Unexpected result when comparing method with variable

2005-04-04 Thread Michael Spencer
David Handy wrote: I had a program fail on me today because the following didn't work as I expected: class C: ... def f(self): ... pass ... c = C() m = c.f m is c.f False I would have expected that if I set a variable equal to a bound method, that variable, for all intents and purposes

RE: Unexpected result when comparing method with variable

2005-04-04 Thread Tony Meyer
[David Handy] > I had a program fail on me today because the following didn't > work as I expected: > > >>> class C: > ... def f(self): > ... pass > ... > >>> c = C() > >>> m = c.f > >>> m is c.f > False [...] > The workaround really awkward: What's wrong with this? >>> class C: ...