Comparisons of incompatible types
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Mon Dec 6 19:17:11 EST 2010
On Mon, 06 Dec 2010 08:59:12 -0800, TomF wrote:
> I'm aggravated by this behavior in python:
>
> x = "4"
> print x < 7 # prints False
> I can't imagine why this design decision was made.
You've never needed to deal with an heterogeneous list?
data = ["Fred", "Barney", 2, 1, None]
data.sort()
Nevertheless, I agree that in hindsight, the ability to sort such lists
is not as important as the consistency of comparisons.
--
Steven
More information about the Python-list
mailing list