porting modules to Python 3.0

Michele Simionato michele.simionato at gmail.com
Wed Dec 3 06:23:37 CET 2008

Python 3.0 is going to be released Real Soon now and I realized
that there big holes in my understanding of how libraries
working both with Python 2.X and Python 3.X should be written.
Let me consider pure Python libraries for the moment.
I see various possibilities:

1. I just release two different libraries, say lib2X.py and lib3X.py,
    the first for the 2.X series and the second for the 3.X series,
    the source code of lib3X.py is generated from lib2X.py via 2to3;
2. I release a single library lib.py which consists in a big if:

$ cat lib.py
if sys.version >= '3':
    from lib3X import *
   from lib2X import *

I am not really happy with any of the options. I think there should be
some cooperation
between PyPI and easy_install such than when the user type

$ easy_install lib

the user gets the 2.X version or the 3.X version according to the
Python version she is using.
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?

                   Michele Simionato

More information about the Python-list mailing list