2

I am still learning python and I started with Python 3. This question not Python 2 vs 3 or difference between them like print() is a function and not language construct and 3/2 = 1.5

My question is even if it is still python, what was the need of introduce something new which is not backward compatible, when -

  1. Syntax is the same
  2. Language philosophy is the same (import this)

Edit - Lets say all the popular packages are ported to Python 3, does that mean we no longer need Python 2

2 Answers2

6

Python 3 was introduced to make improvements upon python 2, but I think what you are asking is why they are not backwards compatible. Basically, developers deliberately made python 3 not backwards compatible, for two main reasons:

  1. First of all, they wanted to change some things integral to python 2, and while the differences seemed small, the improvements that they had made would not have combined well with the existing structure. For example, the change to the "print" syntax you mentioned was made because print really is just calling a function, and really isn't a keyword in the same way that something like "if" or "while" is.

  2. The other reason backwards compatibility was severed was to keep python 2 and 3 separate. Some people, including me, prefer python 2.7 over python 3. Because python 3 made larger changes to the language, developers wanted to maintain the two versions almost as separate (if quite similar) languages.

For all intents and purposes, if you use python 2.7, the only difference that should really affect you is the change in "print".

4

In a talk I heard Guido say something like this:

You do not want your library in the Python standard library. Once it is there you can not change the API if you made any mistake.

So a reason I want to add is:

  • Incompatible changes to the API can only be made between Major Python versions.

Examples:

import SimpleHTTPServer
import CGIHTTPServer

changed to

import http.server
gnat
  • 20,543
  • 29
  • 115
  • 306
User
  • 815