[docs] Control flow - explanation

Kennedy Greg - grkenn Greg.Kennedy at acxiom.com
Tue May 29 20:42:10 CEST 2012

Going through the tutorial for programmers, I noticed an area which might benefit from some improvement.
Code snippet in section 4.4 is followed up by this:
"(Yes, this is the correct code. Look closely: the else clause belongs to the for<http://docs.python.org/reference/compound_stmts.html#for> loop, not the if<http://docs.python.org/reference/compound_stmts.html#if> statement.)"

That's hardly explanatory: if you are unfamiliar with the use of whitespace to designate blocks (say, coming from a language where {} braces normally accomplish the task), then this won't make any sense.  This seems as good a place as any to begin addressing the "white space as a control structure" aspect of Python, perhaps with a demonstration that adding tabs to the Else: block will result in incorrect behavior.  I don't recall seeing this being mentioned earlier in the tutorial, yet it's an important defining aspect of the grammar.
The information contained in this communication is confidential, is
intended only for the use of the recipient named above, and may be legally

If the reader of this message is not the intended recipient, you are
hereby notified that any dissemination, distribution or copying of this
communication is strictly prohibited.

If you have received this communication in error, please resend this
communication to the sender and delete the original message or any copy
of it from your computer system.

Thank You.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20120529/5dd49ca9/attachment.html>

More information about the docs mailing list