Re: Adding bound methods dynamically... CORRECTED

2005-09-01 Thread Bruno Desthuilliers
Kevin Little a écrit : Oops, sorry, forgot to answer > ''' > I want to dynamically add or replace bound methods in a class. (snip) > Is there a more pythonic way that's as straight forward? What's wrong with: class Foo: pass def method(self): print "%s" % self f = Foo() Foo.method = me

Re: Adding bound methods dynamically... CORRECTED

2005-09-01 Thread bruno modulix
Mike Meyer wrote: > bruno modulix <[EMAIL PROTECTED]> writes: > >>Devan L wrote: >> >>>Kevin Little wrote: >>> >>> I want to dynamically add or replace bound methods in a class. >> >>(snip) >> >> >>>I'm not an expert, but why do you need to dynamically add or replace >>>bound methods? >> >>T

Re: Adding bound methods dynamically... CORRECTED

2005-09-01 Thread Diez B. Roggisch
> > Yes, but rather than going through the contortions you do to bind a > new method into place, why not make the method in question act as a > proxy for the real method? After all, with first-class functions, > that's easy. Because you don't have to write that proxy. Pure lazyness :) Diez --

Re: Adding bound methods dynamically... CORRECTED

2005-08-31 Thread Mike Meyer
bruno modulix <[EMAIL PROTECTED]> writes: > Devan L wrote: >> Kevin Little wrote: >> >>>I want to dynamically add or replace bound methods in a class. > > (snip) > >> I'm not an expert, but why do you need to dynamically add or replace >> bound methods? > > To modify the behaviour at runtime ?-

Re: Adding bound methods dynamically... CORRECTED

2005-08-31 Thread bruno modulix
Devan L wrote: > Kevin Little wrote: > >>I want to dynamically add or replace bound methods in a class. (snip) > I'm not an expert, but why do you need to dynamically add or replace > bound methods? To modify the behaviour at runtime ?-) There are a lot of idioms/patterns in dynamic language

Re: Adding bound methods dynamically... CORRECTED

2005-08-30 Thread Devan L
Kevin Little wrote: > I want to dynamically add or replace bound methods in a class. I want > the modifications to be immediately effective across all instances, > whether created before or after the class was modified. I need this > to work for both old ('classic') and new style classes, at both

Re: Adding bound methods dynamically... CORRECTED

2005-08-30 Thread Kevin Little
#!/usr/bin/env python # Sorry... :} cut/paste error fixed... ''' I want to dynamically add or replace bound methods in a class. I want the modifications to be immediately effective across all instances, whether created before or after the class was modified. I need this to work for both old ('c