New to Python - block grouping (spaces)

Steven D'Aprano steve+comp.lang.python at
Thu Apr 16 12:43:47 CEST 2015

On Thursday 16 April 2015 20:09, Antoon Pardon wrote:

> I beg to differ. The most common occurence is a loop with a break
> condition in the middle I would prefer such a loop to be written as
> follows:
> repeat:
>     some
>     code
> break_when condition:
>     more
>     code

That structure makes no sense to me. Why is the "break_when" *outside* of 
the loop? Why does the "break_when condition" introduce a new block?

> Actually I would prefer a more elaborate scheme but would be contend with
> a possibility like the above. IMO this is the most occuring pattern where
> the logical structure doesn't match the physical structure and it is not
> occuring relevantly less now.

Judging by the above example, I think it may be a good thing that Python 
doesn't allow "more elaborate" indentation schemes.

    do this
    do that
                  do something else important
          and this
sometimes this
          also this
                             but don't do this
  unless today is Tuesday
               # end loop

Simplicity is a virtue.


More information about the Python-list mailing list