У меня есть java Объект, который я хочу передать в Jython и использовать там как класс python. Я знаю, вы можете установить переменные в интерпретаторе с помощью interpreter.set(name,value)
, но это работает только с примитивами. Вот что я попробовал и мое сообщение об ошибке:
public class NeededInPythonClass{
public void doSomething(){}
}
public class Main {
public static void main(String[] args) {
// write your code here
PythonInterpreter interpreter = new PythonInterpreter();
interpreter.set("inPythonVar",new NeededInPythonClass());
interpreter.exec("inPythonVar.doSomething()");
}
}
Exception in thread "main" Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'NeededInPythonClass' object has no attribute 'function'