tags:

views:

116

answers:

3

I have a large infrastructure that is written in Python 2.6, and I recently took a stab at porting to 3.1 (was much smoother than I expected) despite the lack of backwards compatibility.

I eventually want to integrate some of this Python code with a lot of Java based code that we have, and was thinking about giving Jython a try. However, from looking at the Jython tutorials, all the examples are in 2.6 syntax (e.g., print is not yet a function).

Does/will Jython support Python 3.x syntax at present or in the near future? Or should I roll back to 2.6 if I want to eventually use Jython?

+5  A: 

Jython will not support Python 3.x in the near future. For your code, I recommend to keep it in 2.x form, such that 3.x support becomes available by merely running 2to3 (i.e. with no further source changes). IOW, port to 3.x in a way so that the code remains compatible with 2.x.

Martin v. Löwis
Thank you. Most of my difficulties were with the print statement (of all things), so maybe I will create some bridge method that I can change in the future as I migrate between versions. Is Python 3 that different that Jython compatibility would be difficult?
Uri
In Python 2.6 you can do from __future__ import print_function. However I don't know when/if Jython plans to support that.
Lennart Regebro
@Uri: don't worry about the print function. This is *exactly* what 2to3 was designed to support, so if you have manually adjusted it, you have wasted your time :-( As for Jython: yes, implementing Python 3 will be quite some effort. I'm sure it will happen eventually, but you were asking for the near future (e.g. whether anything is in the works).
Martin v. Löwis
@Martin: I appreciate it. I used the print transition to do some cleanups and add internal logging levels so it wasn't a waste. But there are minor things that I had to change.
Uri
Using 3to2 (http://bitbucket.org/amentajo/lib3to2) is also a good option for supporting both versions.
Ants Aasma
A: 

I would expect that the developers will be working towards compatability with 3.0 at this point. Since they released 2.5 in june I'd hope for a 3.0 version no earlier than Jan.-Mar. 2010, but given their slow release cycle, it could be a while.

chills42
A: 

With time 2.x will be surpassed by the new features of his 3.x. If you wish to programming in Python in the future then "the sooner = the better"

Catalin Festila