November 13th, 2004, 03:10 AM
need to convert python code to java
I have a code in python.As i have to my coding in Java,and infact started other part of the coding in java. Now i need to change certain code written in python to Java.
Can anyone suggest me a wayout.
November 13th, 2004, 04:34 AM
Would it not benefit you to switch to coding in Jython? I'm not sure, I;ve only read little bits on Python/Jython.
November 13th, 2004, 04:56 PM
As Rayman says, it is possible to mix python and Java code with Jython. Jython is the Python language implemented in Java, so you can call Java code from Jython, and compile Jython classes into object that can be accessed from Java.
There are disadvantages to this - Jython only implements the version 2.1 features of Python, so no list comprehensions or generators. Not all the Python libraries are available either, but since you have all the Java libraries available that is not a big issue.
Alternatively you could use a Java-Python bridge such as Jpype which allows you to interface Python and Java code.
If neither of these appeals, you can always recode the Python toJava or the Java to Python. Converting Java to Python is easier IMHO, since there are few language structures in Java that do not have an equivalent in Python, but Python has many features that would be hard to convert to Java.
Dave - The Developers' Coach.
November 13th, 2004, 09:30 PM
Why don't you post some or all of your code so people can estimate whether it can be (which probbaly can) and with how much trouble converted to Java?