allowing braces around suites

Kjetil Torgrim Homme kjetilho at yksi.ifi.uio.no
Fri Aug 27 11:42:37 EDT 2004


[Andrew Koenig]:
>
>   [Kjetil Torgrim Homme]:
>   > my suggestion is to allow braces to mark the suites.  Python is
>   > still strictly enforcing indentation, in fact, in some ways it's
>   > stricter then before.
>   
>   The following code is legal today:
>   
>       def foo(x):
>           print x
>       x = 3
>       if x == 3:
>           {
>           foo(x) : 42
>           }
>   
>   Are you proposing to change the meaning of this code?

no, this code still works with my patch.  the opening brace must be at
the same level as the preceding statement.  this is not a problem,
since the insides of a literal dict can't be a valid Python expression
and vice versa, so you'll get a syntax error even if the misplaced
opening brace is mistakenly taken as the beginning of a dict by the
Python parser.

my current patch does have a problem as stated in my original message,
but this is really just a proof-of-concept.  a patch with no backwards
compatibility problems can be prepared if there is interest.
-- 
Kjetil T.



More information about the Python-list mailing list