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

Samuele Pedroni pedronis at bluewin.ch
Fri Feb 27 08:13:40 EST 2004


At 11:25 27.02.2004 +0000, Alan Green wrote:
>Barry Warsaw <barry <at> 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.
>

please, leave the can of worms of "blocks" etc closed, btw

class bar(self) [property]:

can achieve this, but it's really a sucky syntax for that. It's really an 
orthogonal issue wrt PEP318. If someone want to open it, it should really 
write a separate PEP aftering re-reading the old threads.

Thanks. 




More information about the Python-Dev mailing list