Show Menu
Cheatography

PTC Jython Cheat Sheet Cheat Sheet (DRAFT) by

A Syntax and Concept guide explaining distiguishing characteristics of Jython in reference to Java and Python

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Syntax Differ­ences

Java
Python
import wt.que­ry.*;
from wt.query import *
QuerySpec qs = new QuerySpec(WTPart.class);
qs.appendWhere(VersionControlHelper
.getSearchCondition(WTPart.class, true));
qs = QuerySpec(WTPart)
qs.appendWhere(VersionControlHelper
.getSearchCondition(WTPart))
private String getName() { 
    return this.name;
}
def getName():
    return this.name
if (a) {
    doA();
}
else if (b) {
    doB();
}
else{
    doElse();
}
if (a): 
    doA()
elif (b):
    doB()
else:
    doElse()
for (String str : list) {
    System.out.println(str)
}
for item in list:
    print item
 

Command Line Tricks

Start Jython
jython
Inspect Interp­era­tively after running script
jython -i my_scr­ipt.py
Run command
jython -c 'print "Hello, World!"'

Interp­reter Tricks

Underbar "­_" can be used to reuse the last result returned
>>>qr.nextElement()
...wt.part.WTPart:12345
>>> part = _
You can save a method as a variable in Jython
>>> save = PersistenceHelper.manager.save
>>> save(part)