porting modules to Python 3.0

Terry Reedy tjreedy at udel.edu
Wed Dec 3 02:07:53 EST 2008


Martin v. Löwis wrote:
>> Is there something like that already in place? What are the
>> recommendations for library
>> authors willing to support both Python 2.X and 3.X in parallel?
> 
> My recommendation is to use 3.0's build_py_2to3 implementation of
> the build_py command. See Demo/distutils/test2to3.
> 
> You will have a single lib.py, written in 2.x. When you install
> in 3.0, lib2to3 will convert it to 3.x in the build area, and
> then install the 3.0 version.
> 
> That, of course, requires you to adjust lib.py in such a way that
> 2to3 will successfully and completely convert it. In my experience
> (with porting Django) and Mark Hammond's experience (with porting
> PythonWin), this should be always possible. You look at what 2to3
> does, find out what additional modifications need to be done, and
> apply them to the input of 2to3 so that
> a) 2to3 leaves these changes in place
> b) they either have no effect or still work correctly when run
>    in 2.x.
> 
> Regards,
> Martin
> --
> http://mail.python.org/mailman/listinfo/python-list

In one has both 2.x and 3.0 installed, would it easy to install 'lib.py' 
for both?




More information about the Python-list mailing list