jstacks
jstacks

Reputation: 2437

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!

Upvotes: 6

Views: 301

Answers (3)

Lennart Regebro
Lennart Regebro

Reputation: 172249

Your old code only needs to be rewritten if you are switching to Python 3 for that code. For long-running projects this is likely to happen, for many other projects they will die and become obsolete, or the customer will switch to another company to maintain it, and hence you never need to bother.

For the code that does need to run on Python 3 you must port it. This can be very easy, or very difficult, depending on how much you are using both Unicode and binary data, and how many of Python's internals you are relying on.

I would think that the typical Django project would be quite simple to port.

For more information on porting you can see http://python3porting.com .

Upvotes: 1

Dhaivat Pandya
Dhaivat Pandya

Reputation: 6536

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.

Upvotes: 2

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798636

... 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.

Upvotes: 3

Related Questions