开发者

Can Distribute setuptool be used to convert Python 2 packages to Python 3? [duplicate]

开发者 https://www.devze.com 2022-12-29 22:32 出处:网络
This question already has answers here: 开发者_开发技巧 Closed 9 years ago. Possible Duplicate: Can distribute setuptools be used to port packages implemented in python 2 to 3
This question already has answers here: 开发者_开发技巧 Closed 9 years ago.

Possible Duplicate:

Can distribute setuptools be used to port packages implemented in python 2 to 3

Also, does the tool make it easy?


The only thing that Distribute does is that it calls the 2to3 script (supplied with Python 3) that converts a Python 2.x source code to Python 3 using some automatic transformations. Basically, you write your code using Python 2.x and let Distribute convert it to Python 3 when your package is installed on Python 3.

There are several things that Distribute won't do for you, though:

  • It won't check whether the conversion succeeded or not. You should have a fairly exhaustive set of unit tests to ensure that the behaviour of the converted package is correct as not all the transformations can be done automatically by 2to3, and some other transformations it will do might not make sense. Read this case study for more information about porting a real Python package to Python 3 and in particular this section about things not handled by 2to3.

  • It won't convert modules written using the C API of Python (see this question), you will have to convert these yourself.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号