class Test: def __init__(self): self._parent = None @property def parent(self): return self._parent
@parent.setter def set_parent(self, new_parent): self._parent = new_parent p, c = Test(), Test() c.parent = p >py -3 test.py Traceback (most recent call last): File "test.py", line 15, in <module> c.parent = p AttributeError: can't set attribute BTW this does work, but it is not that elegant: class Test: def __init__(self): self._parent = None def get_parent(self): return self._parent def set_parent(self, new_parent): self._parent = new_parent parent = property(get_parent, set_parent) p, c = Test(), Test() c.parent = p -- https://mail.python.org/mailman/listinfo/python-list