Properties vs. get/set-methods
marklists at mceahern.com
Thu Aug 22 14:33:52 CEST 2002
> When using properties, I can't use val to save the state.
> Accessing self.val would lead to infinite recursion here. So, if I
> want to save the state, I'd have to introduce another attribute.
The answer is embodied in this sample code:
self._val = None
def setVal(self, val):
self._val = val
val = property(getVal, setVal)
Where's the infinite recursion in this?
More information about the Python-list