A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2003-January/032406.html below:

[Python-Dev] Extended Function syntax

[Python-Dev] Extended Function syntax"Martin v. Löwis" martin@v.loewis.de
Fri, 24 Jan 2003 12:52:32 +0100
Duncan Booth wrote:
> How about this:
> 
>     class A(object):
>  
>       def foo(self, foo) [property.set]:
>         "Setter for property 'foo'."
>         self.__foo = foo
> 
>       def foo(self) [property.get]:
>         "Getter for property 'foo'."
>         return self.__foo

This is beautiful, but it does not work: when defining the getter, you 
need both the old property, and the new function object. Looking at your 
code

    def set(fn):
        if isinstance(fn, property):
            return property(fn.fget, fn, fn.fdel, fn.__doc__)

you first assume fn is the property object, and then assume it is the 
setter function.

Of course, there is no reason why the namespace-under-construction 
couldn't be passed to the annotation, but that would be an extension to 
the protocol.

Martin




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