Jython question

Alex Martelli aleaxit at yahoo.com
Tue May 22 04:06:17 EDT 2001


"Ron Stephens" <rdsteph at earthlink.net> wrote in message
news:3B085BA0.70F40888 at earthlink.net...
> Does Jython allow the use of "input" , "raw_input" and "print"; or must
> you code the input and output of programs in real Java, not Jython?

It's faster to try than to wonder...:

D:\jython>jython
Jython 2.0 on java1.3.0_02 (JIT: null)
Type "copyright", "credits" or "license" for more information.
>>> x=raw_input("Hello, what's your name: ")
Hello, what's your name: Alex
>>> print "Ciao,",x
Ciao, Alex
>>>

Works fine when interpreting from file too:

D:\jython>type ciao.py
x = raw_input("Hi, your name: ")
print "Ciao,",x

D:\jython>jython ciao.py
Hi, your name: Alex
Ciao, Alex

And also compiling it:

D:\jython>jythonc ciao.py
processing ciao

Required packages:

Creating adapters:

Creating .java files:
  ciao module

Compiling .java to .class...
Compiling with args: ['C:\\jdk1.3.0_02\\bin\\javac', '-classpath',
'd:\\jython\\
jython.jar;;.\\jpywork;;d:\\jython\\Tools\\jythonc;D:\\jython\\.;d:\\jython\
\Lib
;d:\\jython', '.\\jpywork\\ciao.java']
0  Note: Some input files use or override a deprecated API.
Note: Recompile with -deprecation for details.

D:\jython>copy jpywork\ciao*.class
jpywork\ciao$_PyInner.class
jpywork\ciao.class
        2 file(s) copied.

D:\jython>java -cp ".;jython.jar;%CLASSPATH%" ciao
Hi, your name: Alex
Ciao, Alex

D:\jython>


Alex






More information about the Python-list mailing list