On Mon, Jul 11, 2011 at 10:53 AM, Anthony Kong <anthony.hw.k...@gmail.com> wrote: > Thanks again for your input, Thomas. > I normally prefer > not_here = property(lambda self: self.__get_not_here(), lambda self, v: > self.__set_not_here(v)) > than > not_here = property(__get_not_here, __set_not_here) > Because it allows me to have a pair getter/setter (when there is a need for > it). Use of lambda there is ensure derived class of A can provide their > custom version of getter/setter.
The .setter convenience method also makes it a bit easier for derived classes to modify getters and setters: class Base(object): def get_my_property(self): return self._my_property def set_my_property(self, value): self._my_property = value my_property = property(get_my_property, set_my_property) class Derived(Base): def set_my_property(self, value): super(Derived, self).set_my_property(convert(value)) my_property = Base.my_property.setter(set_my_property) -- http://mail.python.org/mailman/listinfo/python-list