3 ms·
Is there a great tool to convert Python 3 to Python 2? I've tried Pasteurize (part of python-future) but it just leaves the "yield from" statements in place, g
by rspeer 11y ago
Is there a great tool to convert Python 3 to Python 2?
I've tried Pasteurize (part of python-future) but it just leaves the "yield from" statements in place, giving syntax errors. And 3to2 does even less, and seems to mostly be a framework for building tools like Pasteurize.
I know this isn't easy, but JavaScript people do it with ES6 transpilers, and ES6 is more different from ES5 than Python 3 is from Python 2.
- JelteF 11y agoThe two libraries I've created both use a combination of 3to2 and pasteurize to convert the python 3 code to python 2. The only issues I've run into are new error types that I could not use. But there seem to be quite some issues open: https://bitbucket.org/amentajo/lib3to2/issues?status=new&status=open https://bitbucket.org/amentajo/lib3to2/issues?status=new&sta... In case you want to see the scripts I use to change the python3 code to python 2 and make it work with pip: https://github.com/JelteF/PyLaTeX/blob/master/convert_to_py2.sh https://github.com/JelteF/PyLaTeX/blob/master/convert_to_py2... https://github.com/JelteF/PyLaTeX/blob/master/setup.py https://github.com/JelteF/PyLaTeX/blob/master/setup.py