J2 paper 0.2.1

David Pokorny davebrok at soda.csua.berkeley.edu
Tue Aug 24 21:03:45 CEST 2004

I think the proposal is fantastic. Very thorough and positive.

    Choice of Keyword:
+1 for 'using'

In another thread (J2 proposal: keyword), we came to some synthesis on
allowing semicolons to separate decorators:

"Nicolas Fleury" <nid_oizo at yahoo.com_removethe_> wrote in message
news:KqlWc.54712$F85.1167861 at wagner.videotron.net...
> Roman Suzi wrote:
> > This surprises me. And this doen't surprise:
> >
> > using:
> >      staticmethod; synchronized; memoize
> > def bar(foo):
> >      "To colon or not to colon? Def is the question."
> >      pass
> +1
> Nicolas

This is a much better idea than what I had originally suggested, and there
is some precedent, namely the simple_stmt form (from Grammar/Grammar).

> simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE

An argument against allowing this: it can lead to some mild abuse, namely

> > using:
> >      staticmethod; synchronized; memoize; accepts(int,int); returns(int)
> > def bar(foo,foo2):
> >      "To colon or not to colon? Def is the question."
> >      pass

>From what I can tell, this is about as bad as it gets as for readability. I
see two rebuttals to this example:

A) accepts(...) and returns(...) are just stopgap measures for what may be
the "optimal function prototype syntax" (I can hear the groans already).

B) As a matter of philosophy, Python both creates the infrastructure to make
readable programs and encourages good coding style that leads to readable
programs but does not actually force you to write readable programs. I think
disallowing the following

> > using:
> >      staticmethod; synchronized; memoize
> >      returns(int); accepts(int,int)
> > def bar(foo,foo2):
> >      "To colon or not to colon? Def is the question."
> >      pass

would be an unjust fate for a decent compromise between readability and

One possible syntax, which mimics Grammar/Grammar:

    small_decorator: dotted_name [ '(' [arglist] ')' ]
    simple_decorator: small_decorator (';' small_decorator)* [';'] NEWLINE
    suite_of_decorators: simple_decorator | NEWLINE INDENT simple_decorator+
    funcdef: ['SpanishInquisition' ':' suite_of_decorators]
             'def' NAME parameters ':'suite


More information about the Python-list mailing list