A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/344339.html below:

Adding bound methods dynamically... CORRECTED

Adding bound methods dynamically... CORRECTED Adding bound methods dynamically... CORRECTEDBruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Thu Sep 1 17:09:12 EDT 2005
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
f.method()

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4