integer >= 1 == True and integer.0 == False is bad, bad, bad!!!

Paul Rubin no.email at nospam.invalid
Mon Jul 12 22:14:38 EDT 2010


Ian Kelly <ian.g.kelly at gmail.com> writes:
> I don't think it's any more egregious than automatic conversions of
> mixed-type expressions, such as 3 + 4.5.  

That could also be explicit: float(3) + 4.5, or 3 + int(4.5).

> If you don't want your ints automatically converted to floats on
> division, then use the integer division operator.  1 // 2 is still 0
> in Python 3.

Sure, I do that, but the issue was that 1/2 was confusing newbies who
don't understand the different characteristics of int and floating
types.  If the idea is to change Python to fix this problem in a
newbie-friendly way, the right fix is to create enlightment by raising
an exception that points out the problem, not sweep it under the rug
with an automatic conversion.



More information about the Python-list mailing list