On 17/12/12 04:19, boB Stepp wrote:
It is apparent that int() does not like strings with floating-point
formats. None of my books (as far as my flipping can tell) or the
below built-in help clarify this:
...
Of course if I type int(float('10.0')) I get the desired 10 .
as indeed will
int(10.0)
So you are right, there is an inconsistency between how int() converts
floating point numbers and how it converts strings. Even stranger since
the underlying atoi() C function appears to handle float strings quite
happily...
So, I am guessing that to convert strings to integers with int() that
the string must already be of integer format? What is the rationale
for setting up int() in this manner?
No idea, you'd need to ask Guido, it's his language :-)
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor