python 2 vs python 3

Basis of comparison Python 3 Python 2
Release Date
 
2008 2000
Function print
 
print ("hello") print "hello"
Division of Integers Whenever two integers are divided, you get a float value When two integers are divided, you always provide integer value.
Unicode
 
In Python 3, default storing of strings is Unicode. To store Unicode string value, you require to define them with "u".
Syntax
 
The syntax is simpler and easily understandable. The syntax of Python 2 was comparatively difficult to understand.
Rules of ordering Comparisons In this version, Rules of ordering comparisons have been simplified. Rules of ordering comparison are very complex.
Iteration
 
The new Range() function introduced to perform iterations. In Python 2, the xrange() is used for iterations.
Exceptions
 
It should be enclosed in parenthesis. It should be enclosed in notations.
Leak of variables
 
The value of variables never changes. The value of the global variable will change while using it inside for-loop.
Backward compatibility Not difficult to port python 2 to python 3 but it is never reliable. Python version 3 is not backwardly compatible with Python 2.
Library
 
Many recent developers are creating libraries which you can only use with Python 3. Many older libraries created for Python 2 is not forward-compatible.
Posted on by