How to bound a method to a instance ?

Emmanuel eastier at free.fr
Sun Feb 8 20:03:25 EST 2004


Hi,


I would like to know how to bound a method to a instance of a class.

One application would be to allow a change in a method after a reload :

module toto :
--------------
class toto:
    def method(self):
(...)


main module :
--------------
import toto

a = toto.toto()
a.method() -> does something ...

reload (toto)
now a is not reloaded...

a.method = toto.toto().method
does not work, because a.method would be bounded to a new instance...


Thanks,

Emmanuel...




More information about the Python-list mailing list