[Python-Dev] Extended Function syntax
Thomas Heller
theller@python.net
30 Jan 2003 21:01:05 +0100
holger krekel <pyth@devel.trillke.net> writes:
> IMO none of the new syntax ideas really have much appeal.
I have the same feeling.
>
> One way to define lightweight properties today is something like
>
> foo = property(
> lambda s: s.__dict__.get('_foo_', 42),
> lambda s,x: s.__dict__.__setitem__('_foo_', x),
> lambda s: s.__dict__.__delitem__('_foo_'),
> "foo property"
> )
and this is something I actually have done, for readonly computed
properties (without docstring), where this is reduced to
foo = property(lambda self: self._bar)
All in all, I'm not so unhappy with the current way.
Thomas