On Sun, Nov 15, 2015 at 1:08 PM, Steven D'Aprano <st...@pearwood.info> wrote:
> number = +raw_input("enter a number: ")
>
> versus:
>
> text = raw_input("enter a number: ")
> try:
>     number = float(text)
> except ValueError:
>     number = int(text)

What kinds of strings can float() not handle but int() can, and in a
program that's going to group floats and ints together as "numbers",
will they ever be useful? I'd be more likely to write this as simply:

number = float(input("Enter a number: "))

(Also, I use Python 3. No raw. But same diff.)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to