Python3 is there. We will need to switch from Python2 to Python3 sooner or later.
Here are some repetitive mistakes I have made (or keep making), when I do the switch.
Trying to combine a full list from my hands-on experience. Please leave me comments for your input!
- 1. More strict rule when print for Python3
print 3/2 # OK in Python2 print 3/2 # error in Pythone3 # SyntaxError: Missing parentheses in call to 'print'
- 2. xrange doesn’t work in Python3 now.
# In python2, Below works. for i in xrange(3): print(i) # But in python3, we get below exception. # NameError: name 'xrange' is not defined
- 3. In python3, you might get float when you’re expecting integer
num=3 print(num/2) # In python2, it's 1 print(num/2) # In python3, it's 1.5