As we find more Python differences that bite us, I'll post them here.
Python 2.7 | Python 3.x | |
In 3.x, print is a function, and therefore must
have parentheses This is the most common code change between versions |
print 12,24 | print (12,24) |
To test whether a dictionary has a key, 2.7's d.has_key() method has been deprecated | d.kas_key('fred') | 'fred' in d |
In 3.x, range() no longer returns a list, but can be used in for loops without change | for i in range(10) # isinstance(range(10),list) # returns True |
for i in range(10) # but... isinstance(range(10),list) # returns False |