On Mon, Jul 11, 2011 at 11:21 AM, Anthony Kong <anthony.hw.k...@gmail.com> wrote: > Awesome, Thomas. The trick only works if there is only one leading > underscore in the method names. > The following example works as I expected for the derived class B. > class A(object): > def __init__(self): > self.__not_here = 1 > def _get_not_here(self): > return self.__not_here > def _set_not_here(self, v): > print "I am called" > self.__not_here = v > not_here = property(lambda self: self._get_not_here(), lambda self, v: > self._set_not_here(v)) > class B(A): > def _set_not_here(self, v): > print "version B" > self.__not_here = v
It shouldn't. You've still got the name __not_here used in both A and B, so that the B version is setting a different attribute than the A version (_B__not_here vs. _A__not_here). -- http://mail.python.org/mailman/listinfo/python-list