Compare different types
examples/pitfalls/compare_equal.py
x = 2 y = "2" print(x == y) with open(__file__) as fh: print(fh == x)
In both Python 2 and Pyhton 3 these return False
examples/pitfalls/compare_input.py
import sys hidden = 42 # would be random if sys.version_info.major < 3: guess = raw_input('Your guess: ') else: guess = input('Your guess: ') if hidden == guess: print("Match!")
Will never match. Even if user types in 42. - Hard to debug and understand as there is no error.