Update with pickle
Leif K-Brooks
eurleif at ecritters.biz
Tue May 25 23:45:50 EDT 2004
Nicolas Fleury wrote:
> Leif K-Brooks wrote:
>> Add interfaces to your object's class for mutability rather than using
>> a low-level hack. Something like this (untested):
>
> Thx for your answer, but according to what I read about __slots__, this
> feature has never been intended to be used that way either, so it's also
> a kinda low-level hack, no? It is still an interesting solution.
Using __slots__ is just an optimization, it isn't directly related to
the example. This would also work:
class cls:
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