Is Jython compatible with Python?

D-Man dsh8290 at rit.edu
Thu May 24 09:59:55 EDT 2001


On Thu, May 24, 2001 at 06:33:31AM -0700, Daniel Klein wrote:
| On Thu, 24 May 2001 08:52:56 +0100, Simon Brunning <SBrunning at trisystems.co.uk> wrote:
| 
| >> From:	Daniel Klein [SMTP:danielk at aracnet.com]
| >> Can modules written in Python be imported and used in Jython? Or do I have
| >> to re-write the code?
| >> What are the limits, if any?
...
| >A *very* few of the modules in the standard library aren't available for
| >Jython, but I have never been caused a problem. YMMV.
| 
| The main reason I ask is that my first attempt to run an existing
| 'unit test' <wink * 2>, I was rewarded with...
| 
| Traceback (innermost last):
|   File "c:\python\jtest.py", line 16, in ?
|   File "c:\python\jukebox.py", line 88, in connect
|   File "c:\python\jukebox.py", line 160, in __init__
|   File "C:\jython\Lib\popen2.py", line 141, in popen2
|   File "C:\jython\Lib\popen2.py", line 33, in __init__
| AttributeError: class 'org.python.modules.os' has no attribute 'pipe'
| 
| So I have to assume that the 'popen2' module has not been implemented.

You have found one of the 2 main limitations of Jython -- the os
module is quite a bit smaller.  The other main limitation is that you
can't use any C extension libraries.

As I'm sure you can figure out these limitations are not Jython nor
the Jython developers' fault -- they are trying to develop on top of
the Java platform and must live with its limitations.

If you write pure Python (no C) code that doesn't use any os or
platform specific features then it should work just fine (though a bit
slower) using jython.

-D





More information about the Python-list mailing list