import javax.script.ScriptEngineManager as ScriptManager import javax.script.ScriptException as ScriptException import org.python.util.PythonInterpreter as PythonInterpreter interp = PythonInterpreter() interp.exec("class MyInt(int): pass") print "Type MyInt expected" interp.exec("x = MyInt(); print type(x)") manager = ScriptManager() engine = manager.getEngineByName("python") engine.eval("class MyInt(int): pass") print "Type MyInt expected" engine.eval("x = MyInt(); print type(x)")