3-Python 2.x and Python 3.x
3-Python 2.x and Python 3.x
Although development of Python started in the late 80’s, Python 1.0 was published in
January 1994. Some important features like cycle-detecting garbage collector and
Unicode support were added in Python 2.0 which was released in October 2000.
Python 3.0 was released in December 2008. It was designed to rectify certain flaws in
earlier version. The guiding principle of Python 3 was: "reduce feature duplication by
removing old ways of doing things". Python 3.0 doesn’t provide backward
compatibility. That means a Python program written using version 2.x syntax doesn’t
execute under python 3.x interpreter. Since all the Python libraries are not fully ported
to Python 3, Python Software Foundation continues to support Python 2. The
foundation has recently announced it will discontinue Python 2 support by year 2020.
Some of the obvious differences between the Python 2.x variants and Python 3.x
variants are displayed below.
Input
Integer division
Numbers that you type without any Evaluates the result of a division as
digits after the decimal point are treated decimals even if the input number are
as integers during division. not specified with decimals.
3/2 3/2
Output = 1 Output = 1.5
Unicode strings
Example:
u’hello’
Long integer
Arithmetic operations over normal Integer objects are long by default and
integers may overflow the memory do not require the trailing L.
allocated to them. To allocate more
memory to an integer object, a trailing L Example:
is attached. 100
Example:
100L