Python comparing int, float, etc to lists -
this question has answer here:
so has been bothering me , haven't been able find online it. please explain behavior in python? why return true rather throwing exception? thanks
in [1]: 1 < [1, 2, 3] out[1]: true
it does throw exception-- these days, anyway:
$ python3 python 3.3.0 (default, apr 17 2013, 13:40:43) [gcc 4.6.3] on linux type "help", "copyright", "credits" or "license" more information. >>> 1 < [1,2,3] traceback (most recent call last): file "<stdin>", line 1, in <module> typeerror: unorderable types: int() < list() python used let comparisons pass in old days because handy able sort automatically in heterogeneous containers, led more bugs did convenience, , fixed in python 3.
Comments
Post a Comment