Python comparing int, float, etc to lists -


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

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -