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/2004-February/042835.html below:

[Python-Dev] Re: new syntax for wrapping (PEP 318)

[Python-Dev] Re: new syntax for wrapping (PEP 318) [Python-Dev] Re: new syntax for wrapping (PEP 318)Alan Green alan.green at cardboard.nu
Fri Feb 27 16:00:35 EST 2004
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 
-- 


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