Guido van Rossum wrote: > > There's something odd about writing > > > > def property foo: > > ... > > > > Both of > > > > defprop foo: > > ... > > > > or > > > > define property foo: > > ... > > > > seem more natural. > > > > def foo [property]: > > ... > > > > anyone? Probably relying on the difference between [ and ( kills it. > > Yes. > > How about > > foo = property: > ... IMO none of the new syntax ideas really have much appeal. 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" ) I don't claim this is a great solution but it is rather efficient syntaxwise. If properties-accessor/modifiers have considerably more body-code then the current overhead of def _getfoo(self, ...): ... def _setfoo(self, ...): ... def _delfoo(self, ...): ... foo = property(_getfoo, _setfoo, _delfoo, "docstring") isn't too bad, either. So I think that any new syntax needs to satisfy more needs than just curing some property-uglyness. Neverthelss, Michael's original patch is in a different class. Maybe property-aspects should be left out of its dicussion. just my 2c, holger
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4