3 ms·
Add me to the list. The other day I was debugging some simple Python code that worked something like return 10000 if x > 10000 else x and it wasn't workin
by repsilat 13y ago
Add me to the list. The other day I was debugging some simple Python code that worked something like
return 10000 if x > 10000 else x
and it wasn't working because x was a string. Instead of raising an exception, though, Python decided that all strings are "greater than" all integers, and code was essentially equivalent to
return x
- masklinn 13y ago> Instead of raising an exception, though, Python decided that all strings are "greater than" all integers Yep. That's one of the things they changed/fixed in Python 3, comparisons are not defined across and between any and all types: >>> "foo" > 3 Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unorderable types: str() > int()