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
--
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?
To modify the behaviour at runtime ?-)
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 = method
Kevin Little wrote:
I want to dynamically add or replace bound methods in a class. I want
I asked a seemingly-unrelated question a week or so ago, and learned
something interesting:
Python 2.3.4 (#2, Jul 12 2004, 12:46:36)
[GCC 3.3] on sunos5
Type help, copyright, credits or license for
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
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 ?-)
There are a
#!/usr/bin/env python
'''
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
#!/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
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