Use of python3 compatibility packages six vs. futurize
Hi python3-porters, At the Ressurection-Sprint in Halle, I learned that most of python 3 porting in zope is done using six <http://pythonhosted.org/six/>. I've stuck to it during the work there, as it seemed to be the standard that other zope packages have adopted. But since futurize <http://python-future.org> offers a much more comprehensible implementation of the 2to3 Script and seems to be better maintained - I'd like to use it instead. Especially because it promises to make porting to py3 while maintaining py2 compatibility easier and faster. Any good reasons (besides consistency) not to use it? Is there some sort of consensus on this topic that has been reached before? Best Regards, Martin Häcker
Hi. I think it is preferable if we stick to a single project, which gets used as a runtime dependency, and since six is already used in many projects, I'd continue to use it everywhere. The 2to3 script or versions thereof shouldn't introduce a new runtime dependency, as you only need to check in the code produced by these scripts, so you can use those just fine. I've also used the zope.fixers project, which extends 2to3 to apply some zope.interface specific conversions. I did run 2to3 on the Zope2 project and the result wasn't all too helpful. There were many instances were the conversion produced invalid results or changed behavior in undesirable ways, so I ended up manually fixing and looking at each change anyways. One thing I do find helpful is running a Python 3 pep8/flake8 over the codebase, as it points out most of the places where you have invalid Python 3 syntax. Just my 2 cents, Hanno On Tue, Oct 4, 2016, at 11:29, Martin Häcker wrote:
Hi python3-porters,
At the Ressurection-Sprint in Halle, I learned that most of python 3 porting in zope is done using six <http://pythonhosted.org/six/>.
I've stuck to it during the work there, as it seemed to be the standard that other zope packages have adopted.
But since futurize <http://python-future.org> offers a much more comprehensible implementation of the 2to3 Script and seems to be better maintained - I'd like to use it instead. Especially because it promises to make porting to py3 while maintaining py2 compatibility easier and faster. Any good reasons (besides consistency) not to use it? Is there some sort of consensus on this topic that has been reached before?
Best Regards, Martin Häcker
Hi, On 04.10.16 13:49, Hanno Schlichting wrote:
I think it is preferable if we stick to a single project, which gets used as a runtime dependency, and since six is already used in many projects, I'd continue to use it everywhere.
That does make a lot of sense - hence why I stuck with six and asked this question here.
The 2to3 script or versions thereof shouldn't introduce a new runtime dependency, as you only need to check in the code produced by these scripts, so you can use those just fine. I've also used the zope.fixers project, which extends 2to3 to apply some zope.interface specific conversions.
zope.fixers is new to me - I'l have a look there. Regarding 2to3 of futurize: It does depend on futurize, as futurize provides backports of the new python3 types (bytes most prominently, but pretty much all of them) and knows how to import and use them from futurize. So it does do stuff other 2to3 utilities can't do.
One thing I do find helpful is running a Python 3 pep8/flake8 over the codebase, as it points out most of the places where you have invalid Python 3 syntax.
futurizes 2to3 shell script implementation is called 'futurize' and it can run in multiple stages. Stage1 will just upgrade code to idomatic python 2.7 so you can get rid of almost all the incompatible syntax with strong guarantees that no intention change is done. Also, since this doesn't add any dependency on futurize, its something I can recommend.
Just my 2 cents, Hanno
Thanks! :) Martin
participants (2)
-
Hanno Schlichting -
Martin Häcker