Skip to Content.
Sympa Menu

byte-of-python - [Byte-of-Python] Suggestion: rephrase explanation of while-else

byte-of-python AT lists.ibiblio.org

Subject: Discussion regarding the book 'A Byte of Python'

List archive

Chronological Thread  
  • From: Manish Malik <mm AT bbspals.org>
  • To: byte-of-python AT lists.ibiblio.org
  • Subject: [Byte-of-Python] Suggestion: rephrase explanation of while-else
  • Date: Sun, 24 Jul 2005 18:04:02 +0530

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hi,

A quick note of Thanks for the book :-)
and a suggestion:

Chapter 6 (Control Flow), The while statement:
- -----------------------------------------------
"If there is an else clause for a while loop, it is always executed
unless you have a while loop which loops forever without ever breaking
out!"

This is followed by:
"The else-block is actually redundant since you can put those
statements in the same block (as the while statement) after the while
statement to get the same effect."


Here, the reader may get an impression of the definiteness that the
else-clause is *always* executed unless the while loops forever.
However, this is not the case (as stated in the quoted text from
'break statement' section below.) The else-block is not redundant,
since it may contain statements that need to be executed only in case
of a non-break (i.e. not using the 'break' statement) exit from the loop.


A couple of sections later, 'The break statement':
- --------------------------------------------------

"An important note is that if you break out of a for or while loop,
any corresponding loop else block is not executed."


I would suggest that a reference to this fact be included in the
'while statement' section. This may get things straight for the user
who reads this particular section in isolation.

Comments?

Thanks,
Manish

mm .at. bbspals .dot. org
mm .dot. bbspals .dot. org


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFC44q69364pdQFFqARAnh5AJ4g/q7QTcfu+gmIOSEPDAeeFUOkaACdFsw1
04elcLFxnZ6S/Hr9nuQa/AU=
=bTJk
-----END PGP SIGNATURE-----





Archive powered by MHonArc 2.6.24.

Top of Page