An interesting beginner question: why we need colon at all in the python language?

Wanderer wanderer at dialup4less.com
Thu Jul 14 11:14:01 EDT 2011


On Jul 14, 10:34 am, Grant Edwards <inva... at invalid.invalid> wrote:
> On 2011-07-13, Thorsten Kampe <thors... at thorstenkampe.de> wrote:
>
> > * Grant Edwards (Wed, 13 Jul 2011 13:03:22 +0000 (UTC))
> >> On 2011-07-13, Thorsten Kampe <thors... at thorstenkampe.de> wrote:
>
> >> >> and that that block is to be considered in relation to what was just
> >> >> said, before the colon.
>
> >> > The indentation makes it abundantly clear to the human reader that
> >> > that indented block is to be considered in relation to what was just
> >> > said, before the indentation.
>
> >> You would think so, but human readers like redundancy.
>
> > I also like redundancy (and consistency). That's why I'd much more
> > prefer a "then" than a colon which is easily overlooked while reading
> > /and/ while writing.
>
> How is the "then" going to be consistent with other things that also
> introduce blocks (def, try, with, etc.).
>
> --
> Grant Edwards               grant.b.edwards        Yow! !  I'm in a very
>                                   at               clever and adorable INSANE
>                               gmail.com            ASYLUM!!

But if you have the colon, why do you need the brackets or backslashes
in an if statement.

Why not

if condition1 or
   condition2 or
   condition3:
    do_something()

The statement ain't over til there's a colon.





More information about the Python-list mailing list