[Python-Dev] Re: PEP 318: Decorators last before colon (original) (raw)

Terry Reedy tjreedy at udel.edu
Tue Mar 30 21:52:00 EST 2004


"Guido van Rossum" <guido at python.org> wrote in message news:200403302121.i2ULLIM09840 at guido.python.org...

> Another possibility that has been suggested is > > [decorator] > def func(arg, arg):

And one that I currently favor. I'm out of bandwidth to participate on a msg-by-msg basis, but perhaps folks can see if they can come to terms with this solution?

Taking the prefix position as given for the moment, why overload list literal syntax versus something currently illegal and meaningless? Such as

[[decorator]] # easy enough to type, or # almost as easy, or <>

Is there near precedent in other languages that I don't know of?

Regardless of syntax, the way I would think of the process (ie, 'come to terms with it') is this: a string literal immediately after a function heading automagically sets the special doc attribute. A list literal (if that is what is used) automagically set a special postprocess attribute which is read once after the body is compiled and deleted when no longer needed. As I understand the proposal, the actual storage would be elsewhere in the interpreter, so the above would be 'as if'. But, would it be useful for later introspection to actual set and leave such an attribute that records the decorator processing of the function?

Terry J. Reedy



More information about the Python-Dev mailing list