[Python-Dev] Re: PEP 318: Decorators last before colon

Samuele Pedroni pedronis at bluewin.ch
Wed Mar 31 19:09:59 EST 2004


>
>Well, it is worrying me. Each special case is one more thing that adds a 
>burden to using Python. The fact that whitespace and comments are allowed 
>between the decorator and function definition is particularly worrying to 
>me - it can quite easily mask errors in code - particularly newbie errors:
>
>     [a]  # oops - I copied this from an interactive session and forgot to 
> modify it.
>
>     # This is a simple function
>     def func (args):
>         pass

I'm not invested into this in any way, but the variations

+[classmethod]
def f(cls):
   pass

or

-[classmethod]
def f(cls):
   pass

are syntactically valid today but OTOH differently from plain [...] 
correspond to run-time errors.

/[classmethod]
def f(cls):
   pass

*[classmethod]
def f(cls):
   pass

even better are syntax errors but are really ugly.

I could live with the +[...] form, as I can live

[...]
def f(...):

or

def f(...) [...]:

it's really a matter of "practicality beats purity" and a 
compromise/balance issue.

The limits of the parser aren't helping either in this case. 




More information about the Python-Dev mailing list