Update with pickle
Leif K-Brooks
eurleif at ecritters.biz
Tue May 25 15:09:58 EDT 2004
Nicolas Fleury wrote:
> I want to update the content of an object with a dumped object of the
> same type so that all reference to existing object are still valid.
Add interfaces to your object's class for mutability rather than using a
low-level hack. Something like this (untested):
class cls(object):
__slots__ = ('foo')
def __init__(self, foo=None):
self.foo = foo
def set_foo(self, foo):
self.foo = foo
foo = cls(42)
bar = foo
print bar.foo # 42
foo.set_foo(43)
print bar.foo # 43
More information about the Python-list
mailing list