Cheatography
https://cheatography.com
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 Differences
Java |
Python |
|
|
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 |
|
Inspect Interperatively after running script |
|
Run command |
jython -c 'print "Hello, World!"'
|
Interpreter 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)
|
|