What are built-in Python 3 types that can be compared to each other?
问题 In Python 2, it was possible to compare objects of different types such as int to str by having an implicit comparison of the text string of types (that is, in lexicographic order, string 'int' is less than string 'str' and string 'list' is less than string 'tuple' ). Hence, in Python 2, 5 < 'hello' returns True . One can read more about why this was allowed in answer to Why is ''>0 True in Python?. In Python 3, this raises builtins.TypeError: unorderable types: int() < str() exception. This