[docs] Sloppy example at sect 8.3 of Python 2.7.3 tutorial
Sandro Tosi
sandro.tosi at gmail.com
Sun Jul 1 19:35:36 CEST 2012
Hello Greg,
thanks for your email.
On Sat, Jun 23, 2012 at 11:51 PM, Greg Edwards <gedwards2 at gmail.com> wrote:
> Hi,
>
> At http://docs.python.org/release/2.7.3/tutorial/errors.html sect 8.3,
> the first example block should ask the user for an "integer", not just a
> "number". I happily entered 1.23 without thikning too much and it failed.
If you enter 1.23 you've just tested the except branch:
>>> while True:
... try:
... x = int(raw_input("Please enter a number: "))
... break
... except ValueError:
... print "Oops! That was no valid number. Try again..."
...
Please enter a number: 1.23
Oops! That was no valid number. Try again...
Please enter a number:
As far as I can see, the example works as expected, and there's
nothing wrong with it (not even the imprecise indication of what
number to enter).
Cheers,
--
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi
More information about the docs
mailing list