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

Bob Ippolito bob at redivi.com
Fri Feb 27 07:07:07 EST 2004


On Feb 27, 2004, at 6:25 AM, 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.

That can already be done with class syntax (and an appropriate metaclass), without touching anything's locals.

-bob



More information about the Python-Dev mailing list