I've often been frustrated by the inability of the built-in propertyI didn't read the rest of the thread, but I think Python 2.6 may have
descriptor to handle anything other than a read-only property when
used as a decorator. Furthermore, read/write/delete properties take
their doc-string and property definition at a non-intuitive and
awkward place (after the getter/setter/delter functions). The
following are three possible solutions to this problem (inspired by
messagehttp://groups.google.com/group/comp.lang.python/msg/9a56da7ca8ceb7c7).
I don't like the solution in that thread because it uses apply() which
will go away in Python 3.
want you want:
class A(object):
@property
def my_prop(): return self._prop
@my_prop.setter
def my_prop(prop): self._prop = prop
@my_prop.deleter
def my_prop(): del self._prop