how to update objects?
Mike 'Cat' Perkonigg
blablu at gmx.net
Tue May 30 04:19:51 EDT 2000
More information about the Python-list mailing list
Tue May 30 04:19:51 EDT 2000
- Previous message (by thread): destructors -- when are they called?
- Next message (by thread): how to update objects?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
loewis at informatik.hu-berlin.de (Martin von Loewis) wrote in <p6q4s7h5q63.fsf at informatik.hu-berlin.de>: >noemail at nowhere.hades (Mike Cat) writes: > >> I update a class with 'reload (module)'. >> How can I update the instances too? > >You'd have to find the instance one-by-one. If you manage to get hold >of them, you can set their __class__ attribute to the new class: > >>>> class A: >... def doit(self):print "old" >... >>>> a=A() >>>> class A: >... def doit(self):print "new" >... >>>> a.doit() >old >>>> a.__class__=A >>>> a.doit() >new > >Regards, >Martin > > Yes, I found this way too, but I thought there could be a better way (or maybe a cleaner) to do this. Thank you! Regards, Mike
- Previous message (by thread): destructors -- when are they called?
- Next message (by thread): how to update objects?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list