PEP318 alternate syntax idea
Jim Jewett
JimJJewett at yahoo.com
Wed Mar 24 23:33:23 EST 2004
Skip Montanaro <skip at pobox.com> wrote in message news:<mailman.305.1080075847.742.python-list at python.org>...
> Jim> With decorators, the function definition itself is normal
> Jim> (and therefore should not be indented); it is the decorators
> Jim> that run at an unexpected time.
> Jim> using:
> Jim> decorator1
> Jim> decorator2
> Jim> decorator3
> Jim> def a (args):
> Jim> pass
> Note that the undent at the end of the using: block also implies
> that "we're done" with the block. If I wrote
> using:
> decorator1
> decorator2
> decorator3
> def a (args):
> pass
> def b (args):
> pass
> would a and b both be decorated or just a? What about if I wrote
Just a. (If you want grouping, then you'll need a third header
clause to indicate that the using is done.)
if blocks (and for and while blocks, with the else) have the same issue.
The grammar production continues if and only if the next non-indented
line is a valid continuation header clause.
if test:
stmt
stmt
elif: # elif continues an if
stmt
stmt
else: # else continues an if
stmt
if test:
stmt
x = 5 # a binding does not continue an if; now it is over.
> using:
> decorator1
> decorator2
> decorator3
> x = really_complex_default()
> def a (arg1, arg2=x):
> pass
> Would a be decorated or not?
Syntax error. using: header clause not followed by def: or
class: header clause.
The one part that feels awkward to me is that the optional
clause (using:) comes first instead of second (elif:) or
last (else:).
-jJ
More information about the Python-list
mailing list