Colon and underscores

Dirck Blaskey dirck at pacbell.net
Sat Jul 28 22:09:23 EDT 2001


"Neil Hodgson" <nhodgson at bigpond.net.au> wrote in message news:<L6H87.69279$Xr6.307583 at news-server.bigpond.net.au>...
> ...The colon is really only needed when you
> want to place the body on the same line:
> 
>     if a: b = 1

>From May, 2000: 
Re: Python Grammar (was Re: A TYPICAL NEWBIE MISTAKE?) 
===================================================================
Oddly enough, the parser doesn't really need the colon here either.
It can manage to figure out where the if expression ends without it.

The colon is almost entirely for readability purposes.
(there are a couple of places where ambiguity occurs without it).
===================================================================
This has been tested in a colon-optional Python 1.5.2.

Just FYI - I couldn't resist pointing that out again.

d



More information about the Python-list mailing list