Adding bound methods dynamically... CORRECTED

Mike Meyer mwm at mired.org
Wed Aug 31 22:19:30 EDT 2005


bruno modulix <onurb at xiludom.gro> 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 ?-)
>
> There are a lot of idioms/patterns in dynamic languages that seems
> somewhat alien at first, then become an obvious solution. When I
> discovered first-class functions and anonymous functions with Python
> some years ago, I wondered what could be the use of such things. Now I
> couldn't live without...

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.

       <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list