Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save litzomatic/2421911 to your computer and use it in GitHub Desktop.
Save litzomatic/2421911 to your computer and use it in GitHub Desktop.
Python: A bug waiting to happen.
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