Thufir
Thufir

Reputation: 8487

SyntaxError: mismatched input 'print' expecting INDENT

Having installed Jython to Linux, how do I import sys and print the details?

thufir@doge:~$ 
thufir@doge:~$ jython --version
"my" variable $jythonHome masks earlier declaration in same scope at /usr/bin/jython line 15.
Jython 2.5.3
thufir@doge:~$ 
thufir@doge:~$ jython -i
"my" variable $jythonHome masks earlier declaration in same scope at /usr/bin/jython line 15.
Jython 2.5.3 (, Dec 21 2015, 23:18:42) 
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_111
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> import sys
>>> r=sys.registry
>>> for k in r:
... print k, r[k]
  File "<stdin>", line 2
    print k, r[k]
    ^
SyntaxError: mismatched input 'print' expecting INDENT
>>> exit()
thufir@doge:~$ 

Presumably, this code is for Windows, but should still execute. What type of indent do they mean? I typed exactly as the example. Is there a space or tab not apparent to me?

I tried indenting a bit:

thufir@doge:~$ 
thufir@doge:~$ jython -i
"my" variable $jythonHome masks earlier declaration in same scope at /usr/bin/jython line 15.
Jython 2.5.3 (, Dec 21 2015, 23:18:42) 
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_111
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> r=sys.registry
>>> for k in r:
...  print k, r[k]
...  ;
  File "<stdin>", line 3
    ;
    ^
SyntaxError: mismatched input ';' expecting DEDENT
>>> exit()
thufir@doge:~$ 

Upvotes: 0

Views: 8753

Answers (1)

Thufir
Thufir

Reputation: 8487

If one of you guys wants points, I'll accept your answer of course. Here's how I got it working:

thufir@doge:~$ 
thufir@doge:~$ jython -i
"my" variable $jythonHome masks earlier declaration in same scope at /usr/bin/jython line 15.
Jython 2.5.3 (, Dec 21 2015, 23:18:42) 
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_111
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> r=sys.registry
>>> for k in r:
...  print k, r[k]
... 
java.runtime.name Java(TM) SE Runtime Environment
python.cachedir /home/thufir/.jython-cache
sun.boot.library.path /usr/lib/jvm/java-8-oracle/jre/lib/amd64
java.vm.version 25.111-b14
java.vm.vendor Oracle Corporation
java.vendor.url http://java.oracle.com/
path.separator :
java.vm.name Java HotSpot(TM) 64-Bit Server VM
file.encoding.pkg sun.io
user.country CA
sun.java.launcher SUN_STANDARD
sun.os.patch.level unknown
python.console.readlinelib Editline
java.vm.specification.name Java Virtual Machine Specification
user.dir /home/thufir
java.runtime.version 1.8.0_111-b14
java.awt.graphicsenv sun.awt.X11GraphicsEnvironment
java.endorsed.dirs /usr/lib/jvm/java-8-oracle/jre/lib/endorsed
os.arch amd64
python.home /usr
java.io.tmpdir /tmp
line.separator 

java.vm.specification.vendor Oracle Corporation
os.name Linux
sun.jnu.encoding UTF-8
python.console org.python.util.ReadlineConsole
java.library.path /usr/lib/jni
java.specification.name Java Platform API Specification
java.class.version 52.0
sun.management.compiler HotSpot 64-Bit Tiered Compilers
os.version 4.4.0-21-generic
python.executable /usr/bin/jython
user.home /home/thufir
user.timezone 
java.awt.printerjob sun.print.PSPrinterJob
file.encoding UTF-8
java.specification.version 1.8
java.class.path /usr/share/java/jython.jar:/usr/share/java/antlr3-runtime-3.2.jar:/usr/share/java/stringtemplate.jar:/usr/share/java/antlr3-3.2.jar:/usr/share/java/asm3.jar:/usr/share/java/asm3-commons.jar:/usr/share/java/asm3-tree.jar:/usr/share/java/jnr-constants.jar:/usr/share/java/guava.jar:/usr/share/java/jsr305.jar:/usr/share/java/jnr-posix.jar:/usr/share/java/jffi.jar:/usr/share/java/jnr-ffi.jar:/usr/share/java/jnr-x86asm.jar:/usr/share/java/jnr-netdb.jar:/usr/share/java/livetribe-jsr223.jar:/usr/share/java/jline.jar:/usr/share/java/servlet-api-3.1.jar:/usr/share/java/libreadline-java.jar
user.name thufir
python.console.encoding UTF-8
java.vm.specification.version 1.8
sun.java.command org.python.util.jython -i
java.home /usr/lib/jvm/java-8-oracle/jre
sun.arch.data.model 64
user.language en
java.specification.vendor Oracle Corporation
awt.toolkit sun.awt.X11.XToolkit
java.vm.info mixed mode
java.version 1.8.0_111
java.ext.dirs /usr/lib/jvm/java-8-oracle/jre/lib/ext:/usr/java/packages/lib/ext
sun.boot.class.path /usr/lib/jvm/java-8-oracle/jre/lib/resources.jar:/usr/lib/jvm/java-8-oracle/jre/lib/rt.jar:/usr/lib/jvm/java-8-oracle/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-8-oracle/jre/lib/jsse.jar:/usr/lib/jvm/java-8-oracle/jre/lib/jce.jar:/usr/lib/jvm/java-8-oracle/jre/lib/charsets.jar:/usr/lib/jvm/java-8-oracle/jre/lib/jfr.jar:/usr/lib/jvm/java-8-oracle/jre/classes
java.vendor Oracle Corporation
python.path /usr/lib/site-python:/usr/share/jython/Lib
file.separator /
java.vendor.url.bug http://bugreport.sun.com/bugreport/
sun.io.unicode.encoding UnicodeLittle
sun.cpu.endian little
sun.desktop gnome
sun.cpu.isalist 
>>> 
>>> exit()
thufir@doge:~$ 

I knew that python used white space, but, so far as I could tell was following the example tutorial. Not to get defensive, but they could mention to press enter twice. Anyhow, great comments, thanks, got it.

Upvotes: 1

Related Questions