Paul Prescod wrote: > > PEP: ??? > Title: Computed Attributes > Version: $Revision: 1.0 $ > Owner: paul@prescod.net > Python-Version: 2.0 > Status: Incomplete > > Introduction > > This PEP describes a feature to make it easier to use Python > attribute set/get/del syntax to fetch the results of a computation > or to invoke computation. This feature has been emulated using > __getattr__/__setattr__/__delattr__ but this approach suffers > severe usability and performance concerns. > > Syntax > > Special methods should declare themselves with declarations of the > following form: > > class x: > def __get_foo__(self ): ... def __set_foo__(self, value ): ... > def __del_foo__(self ): ... > > They are used like this: > > fooval=x.foo > x.foo=fooval+5 > del x.foo I don't get the point: how is this better than defining explicit access methods ? get_foo(self) set_foo(self, value) del_foo(self) These not only define a distinct interface, but also provide more flexibility, e.g. get_foo() could have a default argument. -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/
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