I'm aggravated by this behavior in python:

x = "4"
print x < 7    # prints False

The issue, of course, is comparisons of incompatible types. In most languages this throws an error (in Perl the types are converted silently). In Python this comparison fails silently. The documentation says: "objects of different types *always* compare unequal, and are ordered consistently but arbitrarily."

I can't imagine why this design decision was made. I've been bitten by this several times (reading data from a file and not converting the numbers before comparison). Can I get this to throw an error instead of failing silently?

Thanks,
-Tom

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to