A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2007-November/075085.html below:

[Python-Dev] Declaring setters with getters

[Python-Dev] Declaring setters with getters [Python-Dev] Declaring setters with gettersDuncan Booth duncan.booth at suttoncourtenay.org.uk
Thu Nov 1 12:28:09 CET 2007
"Steven Bethard" <steven.bethard at gmail.com> wrote in news:d11dcfba0710311943u3f6fe4b1x12f1ee659ea51823 at mail.gmail.com:

> On 10/31/07, Fred Drake <fdrake at acm.org> wrote:
>> If I had to choose built-in names, though, I'd prefer "property",
>> "propset", "propdel".  Another possibility that seems reasonable
>> (perhaps a bit better) would be:
>>
>>    class Thing(object):
>>
>>        @property
>>        def attribute(self):
>>            return 42
>>
>>        @property.set
>>        def attribute(self, value):
>>            self._ignored = value
>>
>>        @property.delete
>>        def attribute(self):
>>            pass
> 
> +1 on this spelling if possible.  Though based on Guido's original
> recipe it might have to be written as::
> 
>       @property.set(attribute)
>       def attribute(self, value):
>           self._ignored = value
> 
It *can* be written as Fred suggested: see 
http://groups.google.co.uk/group/comp.lang.python/browse_thread/thread/b442d08c9a019a8/8a381be5edc26340

However that depends on hacking the stack frames, so the 
implementation probably isn't appropriate here.
More information about the Python-Dev mailing list

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