Warm tip: This article is reproduced from serverfault.com, please click

How to use 2to3 properly for python?

发布于 2013-12-08 19:35:20

I have some code in python 2.7 and I want to convert it all into python 3.3 code. I know 2to3 can be used but I am not sure exactly how to use it.

Questioner
GhostFrag1
Viewed
0
3,711 2020-11-27 09:49:39

Install the following module which adds the 2to3 command directly to entry_points.

pip install 2to3

As it is written on 2to3 docs, to translate an entire project from one directory tree to another, use:

2to3 --output-dir=python3-version/mycode -W -n python2-version/mycode