User avatar
bonzadog
Posts: 272
Joined: Wed Apr 25, 2012 9:40 am
Location: Rietberg/Germany

Python2 to python 3 converter

Sat Nov 24, 2018 2:17 pm

By accident, I discovered that STRETCH has a python2 to python3 converter.
called 2to3
Seems to work on the small Python2 programme I converted.

I am waiting for the day when python3 finally get to be standard, but it appears there a still a lot on P2 programmes in use.
Pity Python was not backwards compatible.

hippy
Posts: 10303
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Python2 to python 3 converter

Sat Nov 24, 2018 8:43 pm

bonzadog wrote:
Sat Nov 24, 2018 2:17 pm
Pity Python was not backwards compatible.
Yes, and I think we are going to still be hearing that for many years to come. Along with the accompanying debate on how they could have done it differently and arguments whether what they did was the right or wrong choice.

On one hand 2to3 does a lot, but for most trivial code it actually does very little, and most of the differences could have been handled in some other way which would have made it more backwards compatible.

But we're stuck with what we have. At least for now.

https://docs.python.org/2/library/2to3.html

gkreidl
Posts: 6345
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Python2 to python 3 converter

Sat Nov 24, 2018 10:06 pm

A much better solution (and good docs) can be found here:
http://python-future.org/index.html
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

User avatar
paddyg
Posts: 2615
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Python2 to python 3 converter

Sun Nov 25, 2018 8:51 am

Much, much better to have code that works with both 2 and 3. python-future looks good, or six, which we used for our module. 95% of changes are print-=-print() which are trivial to fix (3% unicode/byte related 1% httprequest 1% other)
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

Return to “Python”