New to Python - block grouping (spaces)

Antoon Pardon antoon.pardon at rece.vub.ac.be
Thu Apr 16 09:57:41 EDT 2015


On 04/16/2015 03:41 PM, Chris Angelico wrote:
> The case of a loop structure with its condition in the middle is one
> that few languages support, so the physical structure has to be
> something like:
>
> goto middle
> while not condition:
>     more code
>     label middle
>     some code
>
> or
>
> while True:
>     some code
>     if condition: break
>     more code
>
> or maybe
>
> some code
> while not condition:
>     more code
>     some code
>
> But I'm not sure how you could represent this more appropriately,
> regardless of your indentation. Unindenting an "if" in the middle of a
> loop doesn't instantly scream "this is the loop header". Using a goto
> to jump half way into a loop is a really REALLY bad idea in most
> programs (and it's illegal in lots of languages anyway). Repeating the
> setup code is fine if it's a single line, but not else.
>
I'm not going to argue the merrits of various indentations styles. I
just wanted to protest the notion, that because one indents one's programs
in languages that don't require indentations, one can't have a quarrel
with how python forces you to indent.

A choice was made and although I would have preferred otherwise, I can
live with it.

-- 
Antoon Pardon




More information about the Python-list mailing list