Created
April 19, 2012 15:50
-
-
Save litzomatic/2421911 to your computer and use it in GitHub Desktop.
Python: A bug waiting to happen.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Python2 vs Python3 | |
A bug waiting to happen. | |
Python2 | |
>>> x = 1 | |
>>> y = '234' | |
>>> x == y | |
False | |
>>> x < y | |
True | |
>>> x > y | |
False | |
Python3, quite a bit better IMO | |
>>> x = 1 | |
>>> y = '234' | |
>>> x == y | |
False | |
>>> x < y | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
TypeError: unorderable types: int() < str() | |
>>> x > y | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
TypeError: unorderable types: int() > str() | |
>>> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment