Re: multi-statement lines ( why can't I ... )

Guido.van.Rossum@cwi.nl
Sat, 11 Dec 1993 00:19:13 +0100

> Why can't I use a multi-statement line like:
>
> >>>for x in list: if x[:len(key)] == key : print x
>
> without getting an invalid syntax message ?

Where would you put an 'else' belonging to the 'if'?

If you say "then disallow else clauses" this would mean the grammar
would have to have else-less variants of if, while and for (at least).

> I could live without the whole statement on one line,
> but I would LIKE to have the selector statements be
> one line, as in:
>
> >>>for x in list: if testof(x) :
> ... do_somthing

Even worse. Here an 'else' indented the same as the 'for' would
really be ambiguous.

--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>