Why aren't colons optional?
brueckd at tbye.com
brueckd at tbye.com
Sun Jan 20 14:49:11 EST 2002
On Sun, 20 Jan 2002, Roy Smith wrote:
> Robert Amesz <sheershion at mailexpire.com> wrote:
> > So don't complain or question, but *cherish* the consistency of Python.
> > It is a great bonus.
>
> Even python isn't completely consistant about ":" introducing an indented
> block. Consider for example:
>
> x = {'a':
> 1,
> 'b':
> 2
> }
>
> I have no idea why anybody would want to write it that way, but it's legal.
It's an indented block, yes, but not a code block in Python's grammar (in
the grammer it's called a 'suite'). In this sense Python is very
consistent: at *no* time (IIRC) in Python's grammar is a suite *not*
preceded by a colon.
-Dave
More information about the Python-list
mailing list