int('2.1') does not work while int(float('2.1')) does

Erik Max Francis max at alcyone.com
Tue Apr 6 00:14:16 EDT 2004


Joe Mason wrote:

> Why can it make this guess for "int(2.1)", then?  It's got a rule for
> converting floats to ints - why not use it here?

Because int(aFloat) means round toward zero.  int(aString) means make an
int out of this string.

-- 
 __ Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
/  \ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
\__/ Convictions are more dangerous enemies of truth than lies.
    -- Friedrich Nietzsche



More information about the Python-list mailing list