Phillip J. Eby <pje <at> telecommunity.com> writes: > At 11:25 AM 2/27/04 +0000, Alan Green wrote: > >It would be really spiffy if the decorator were able to run the decorated > >function and then have access to the function's locals dictionary. It would > >then be possible to define a property like so: > > > >class Foo(object): > > def bar(self) [property]: > > """ bar property docstring """ > > def get(self): > > return self.__bar > > def set(self, bar): > > self.__bar = bar > > -1. There were better alternatives proposed in the previous discussion on > PEP 218 and properties, like: > > def bar(self) [property_get]: > # ... > > def bar(self,value) [property_set]: > # ... > > def bar(self) [property_del]: > # ... defs-inside-defs is a bit wierd, but has some advantages over individual methods: * Tells the reader that the get/set/del belong together * Gives a name to the property once, rather than one name three times * Makes a sensible place for the property's docstring Perhaps it might make more sense as: class Foo(object): def [property] bar: def get(self): ...etc... In which case, it truly is getting beyond the scope of PEP318. -- Alan --
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