Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make the Move to Python 3 - Best practices [closed]

Tags:

We think about whether we should convert a quite large python web application to Python 3 in the near future.
All experiences, possible challenges or guidelines are highly appreciated.

like image 851
Reto Aebersold Avatar asked Apr 26 '10 09:04

Reto Aebersold


People also ask

How do you go back to the start of a while loop in Python?

The continue statement in Python returns the control to the beginning of the while loop. The continue statement rejects all the remaining statements in the current iteration of the loop and moves the control back to the top of the loop. The continue statement can be used in both while and for loops.

How do you stop a Python code if not met?

In Python, the break statement provides you with the opportunity to exit out of a loop when an external condition is triggered. You'll put the break statement within the block of code under your loop statement, usually after a conditional if statement.


2 Answers

My suggestion is that you stick with Python 2.6+, but simply add the -3 flag to warn you about incompatibilities with Python 3.0. Then you can make sure your Python 2.6 can be easily upgraded to Python 3.0 via 2to3, without actually making that jump quite yet. I would suggest you hold back at the moment, because you may at some point want to use a library and find out that it is only available for 2.6 and not 3.0; if you make sure to cleanup things flagged by -3, then you will be easily able to make the jump, but you will also be able to take advantage of the code that is only available for 2.6+ and which is not yet ready for 3.0.

like image 70
Michael Aaron Safyan Avatar answered Sep 23 '22 19:09

Michael Aaron Safyan


For each third-party library that you use, make sure it has Python 3 support. A lot of the major Python libraries are migrated to 3 now. Check the docs and mailing lists for the libraries.

When all the libraries you depend on are supported, I suggest you go for it.

like image 41
codeape Avatar answered Sep 22 '22 19:09

codeape