int('0.0') throws an exception
tjreedy at udel.edu
Thu Jan 30 01:57:56 CET 2003
"Ragu Bharadwaj" <Ragu.Bharadwaj at amphoracorp.com> wrote in message
news:37bc2c.0301291602.7f6c6c4f at posting.google.com...
> Why is it that
> int('0') and int(0.0) are OK but int('0.0') throws an Exception?
Because '0.0' is the sting version of a float, not an int.
int(float('0.0')) work fine.
int() could have been writen to convert the longest digit prefix and
ignore rest, but it was decided that this could too often mask a bug
in your program.
Terry J. Reedy
More information about the Python-list