Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to maintain when Django switches to Python 3?

I am in the process of learning Python and had a question about the future. I know it's not the most pressing thing to think about currently, but I'm curious.

Currently, Django only supports up to Python 2.7. However, in the near future, it will be supporting Python 3. In terms of writing code in Python 2.7 and using the related Django framework, what happens when the transition to Python 3 actually comes along.

Presumably, I'd learn and code in the newer version. However, what about maintaining the old code? Does it stay as is? Does it need to be rewritten?

I'm just curious as to how these transition work. Also, does it make a difference that Python 3 isn't backwards-compatible? What is the consequence of that? For instance, I read that Ruby versions 1.8 to 1.9 (and even the future 2.x) were backwards-compatible and less of a leap (than Python 2.x to 3.x). I wonder if that split between Python versions creates any fragmentation problems or code maintenance problems?

So, if someone could try explaining to me what goes on with these updates and the issues at hand when dealing with them, I'd really appreciate it. Thanks!

like image 280
jstacks Avatar asked Jan 02 '12 06:01

jstacks


People also ask

Is Django compatible with Python3?

Django 1.5 is the first version of Django to support Python 3. The same code runs both on Python 2 (≥ 2.6. 5) and Python 3 (≥ 3.2), thanks to the six compatibility layer.

What version Python can I use with Django?

What Python version should I use with Django? ¶ Since newer versions of Python are often faster, have more features, and are better supported, the latest version of Python 3 is recommended.


2 Answers

... what happens when the transition to Python 3 actually comes along.

Nothing. That's why you're using a framework in the first place. All you need to be responsible for is the small amount of your code that will need to be ported.

like image 185
Ignacio Vazquez-Abrams Avatar answered Oct 05 '22 23:10

Ignacio Vazquez-Abrams


Django (due to the immense amount of code running on it), will not, atleast in the near future, drop support for 2.x. It just doesn't make any sense.

Any Python 3 is having trouble getting adoption right now; PyPy is picking up much, much faster.

And, there's py2to3 which converts some parts to python 2 code to python 3, and then you have to do the rest by hand.

like image 39
Dhaivat Pandya Avatar answered Oct 06 '22 00:10

Dhaivat Pandya