WebSphere Application Server & Liberty

WebSphere Application Server & Liberty

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only

Jython Error: SyntaxError: inconsistent dedent

By Steve Robinson posted Fri February 01, 2013 05:40 PM

  

When running a WAS jython script you get the following error:

WASX7017E: Exception received while running file "f:\script\jython\getCell.py"; exception information: com.ibm.bsf.BSFException: exception from Traceback (innermost last): (no code object) at line 0 File "", line 36 elif value.find( 'WASX7017E' ) > -1 : ^ SyntaxError: inconsistent dedent

In this example screen shot below you can see that the elif statement has been indented by one space too much. It is wise to use a text editor which provides and option to show tabs and space characters, so you can sort out our jython indentation.



Solution:
Delete the extra space, and remember that if you want to use tabs it is best to set your editor if it is possible to use spaces for tab characters, this will save you many late nights debugging tab based indentation vs space based indentation in your jython scripts.

Another reason why it is important to use spaces and not tabs is because as you copy code fom AIX/Linux shells to Windows ie between different text editors they IDE/editing tools. The may disagree on tab width, and if you have mixed tab and spaces during your typing/pasting, you can get a miss match of indentations.

Keep to spaces and use 2 or 4, then you are going to be fine!

0 comments
14 views

Permalink