Python indentation

Mark 'Kamikaze' Hughes kamikaze at
Mon Jul 12 23:42:38 CEST 2004

Antoon Pardon <apardon at>
wrote on 12 Jul 2004 11:19:50 GMT:
> Op 2004-07-09, Mark 'Kamikaze' Hughes schreef <kamikaze at>:
>>   This confuses me as to where the loop starts and ends:
> This confusion may be nothing more than your unfamiliary which
> such a construct.
>> linenum=1
>> while True:
>>     line = raw_input()
>> and while line:
>>     print "%05d:%s" % (linenum, line,)
>>     linenum += 1

  No, I am quite certain that my confusion is due to the block
indentation aimlessly wandering out, then in, then out again, then in at
the end.  And I'm supposed to visually identify that as a single flow of
execution?  Bugger that.

  I've programmed in dozens of languages.  None but BASIC and various
assembly languages have a loop structure quite so ugly as that.

>>   I rarely use post-loop condition testing even in Java where it exists
>> and you can use assignment as an expression, let alone in Python.  When
>> I do, an explicit if...break at the end works fine.
> That is not an argument.

  Actually, it is.  You just didn't follow it.  Python does not have
assignment as expressions, which is a feature that makes post-loop
testing more convenient.  Python does have a practical solution to that
kind of loop already.

  Python wins now because it is simple, and clear, and there's one
explicitly correct way to solve most tasks.

> Before instructions like while, repeat etc
> existed, we could use the equivallent of an if combined with a goto
> and that worked fine too.

  Ah, so your plan is to return to those golden times with equally
incoherent block structures.  Excellent plan.  Here was me thinking you
had no plan, but you did, and it's a *fine* plan.  You go on ahead, I'll
be sure to follow your cutting-edge lead any day now.

 <a href=""> Mark Hughes </a>
"The void breathed hard on my heart, turning its illusions to ice, shattering
 them.  Was reborn, then, free to scrawl own design on this morally blank
 world.  Was Rorschach." --Alan Moore, _Watchmen #6_, "The Abyss Gazes Also"

More information about the Python-list mailing list