Thomas Guettler wrote:
> for debugging I want to raise an exception if an attribute is
> changed on an object. Since it is only for debugging I don't want
> to change the integer attribute to a property.
Why?
> This should raise an exception:
>
> myobj.foo=1
>
> Background:
> Somewhere this value gets changed. But I don't now where.
If you change your mind:
class A(object):
def __init__(self):
self.foo = 42
a = A()
b = A()
class B(A):
@property
def foo(self):
return self.__dict__["foo"]
b.__class__ = B
a.foo = "whatever"
print b.foo
b.foo = "whatever"
Peter
--
http://mail.python.org/mailman/listinfo/python-list