Python 3to2: Go check it out.

August 27th, 2009 § 4 comments

awesome.jpg Ear­lier this week — Joe Amenta shot an email to the Python-Dev mail­ing list announc­ing the com­ple­tion of the Google Sum­mer of Code project he had be work­ing on — a Python 3 to Python 2 trans­la­tion tool.

This is some­thing which, when dis­cussed at the Python Lan­guage Sum­mit at PyCon 2009 was met with much “yes please make this” — but not a lot of peo­ple could allo­cate the time. In fact, when asked who could at least help drive it for­ward, I was lame^H^H^H awe­some enough to raise my hand.

In true upper man­age­ment style, I dis­cussed it, and promptly del­e­gated it to Ben­jamin Peter­son, our release man­ager to later del­e­gate to a google sum­mer of code project.

Some work was done dur­ing the sprints — I don’t know if that work ended up being part of this, but thanks to Joe, we now have the first alpha of a Python 3 to Python 2 con­ver­sion tool.

Here’s Joe’s announce­ment:

Hello all,

I have released the first alpha ver­sion of 3to2 after fin­ish­ing it for my Google Sum­mer of Code 2009™ project. You can get the tar­ball for this release at http://bitbucket.org/amentajo/lib3to2/downloads/3to2_0.1-alpha1.tar.gz. This requires python 2.7, because it requires a newer ver­sion of 2to3 than what comes with 2.6.

Release notes are in the RELEASE file. Devel­op­ment hap­pens at http://bitbucket.org/amentajo/lib3to2/, and the source code for this release lives at http://bitbucket.org/amentajo/3to2-01-alpha-1.
Report bugs at http://bitbucket.org/amentajo/lib3to2/issues/, please.

Addi­tional notes and com­ments can (for now) be found at http://www.startcodon.com/wordpress/?cat=4.

–Joe

This is awe­some — again, major props to Joe (and Ben­jamin!) and GSoC for mak­ing this hap­pen. Please, please, please — if you have free time, go give it a shot. Espe­cially if you have real, honest-to-goodness Python 3 code you’re work­ing with.

Right now, it’s prob­a­bly too early to get near python-core — there’s some dis­cus­sion of that going on in the thread on Python-dev, but I per­son­ally feel if we can bang the hell out of this and get a lot of eyes look­ing at it, it would go a long way towards help­ing Python 3 adop­tion along.

Go check it out — again, the project page is here, and Joe’s notes on things 3to2 does not accept is here.

p.s. The first per­son to write an online 2to3 -> 3to2 app ala trans­la­tion party gets mad props, and a bot­tle of some­thing alco­holic at Pycon.

  • joea­menta

    Haha, I would love to see what comes out of the 2to3 -> 3to2 gen­er­a­tor. I had ini­tially thought about mak­ing it a goal that 2to3 -> 3to2 code would look the same as the orig­i­nal, but as I learned more, I con­ceded that it would be unre­al­is­tic and impractical.

  • http://www.acooke.org/lepl andrew cooke

    awe­some indeed. thanks for this. saw an email ages ago to dev (which i don’t read all of) sug­gest­ing this and then it seemed to dis­ap­pear — gret to see it didn’t get lost. i will give it a go on lepl (see my link) next release (com­ing up soon).

  • don­spauld­ing

    The py-postgresql project might be a good start­ing point for get­ting a real­is­tic Python 3.X code­base back­ported via 3to2.

    http://python.projects.postgresql.org/

    It seems like 3to2 needs to learn how to remove anno­ta­tions and dic­tio­nary com­pre­hen­sions first. Unfor­tu­nately hack­ing 3to2 is a bit beyond me. Sounds like a great idea though.

  • don­spauld­ing

    The py-postgresql project might be a good start­ing point for get­ting a real­is­tic Python 3.X code­base back­ported via 3to2.

    http://python.projects.postgresql.org/

    It seems like 3to2 needs to learn how to remove anno­ta­tions and dic­tio­nary com­pre­hen­sions first. Unfor­tu­nately hack­ing 3to2 is a bit beyond me. Sounds like a great idea though.

    EDIT: Actu­ally, 3to2 does han­dle anno­ta­tions cor­rectly, it was just barf­ing on ParseEr­rors in cer­tain files and then not run­ning any fix­ers on those files. Pro­tip: READ THE OUTPUT.

What's this?

You are currently reading Python 3to2: Go check it out. at jessenoller.com.

meta