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

Phillip J. Eby pje at telecommunity.com
Fri Feb 27 09:10:45 EST 2004


At 11:25 AM 2/27/04 +0000, Alan Green wrote:

Barry Warsaw <barry python.org> writes:

> Just what /is/ the contract for a decorator function? Maybe that it > takes a function/method object and must return a descriptor? I do think > this needs some clarification in the PEP. 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 The property decorator would reach inside the locals dictionary amd pull out the special names 'get', 'set' and 'delete', and use them to construct the property descriptor.

-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]: # ...



More information about the Python-Dev mailing list