On Aug 25, 8:45 pm, Daniel <miller...@gmai l.comwrote:
I didn't read the rest of the thread, but I think Python 2.6 may have
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.delete r
def my_prop(): del self._prop
I've often been frustrated by the inability of the built-in property
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.c om/group/comp.lang.pytho n/msg/9a56da7ca8ceb7c 7).
I don't like the solution in that thread because it uses apply() which
will go away in Python 3.
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.c om/group/comp.lang.pytho n/msg/9a56da7ca8ceb7c 7).
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.delete r
def my_prop(): del self._prop
Comment