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

Joe Mason joe at notcharles.ca
Tue Apr 6 05:12:52 EDT 2004


In article <40722E98.253B5FF2 at alcyone.com>, Erik Max Francis wrote:
> 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.

So why can't int(string) mean round toward zero?

Joe



More information about the Python-list mailing list