public final class PythonInterpreter extends Object implements Interpreter
| Constructor and Description |
|---|
PythonInterpreter(PythonInterpreterConfig config)
Creates a new PythonInterpreter instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
exec(String str)
Execute an arbitrary number of statements in this interpreter.
|
Object |
get(String name)
Retrieves the value to the specified name from the interpreter.
|
<T> T |
get(String name,
Class<T> clazz)
Retrieves the value to the specified name from the interpreter.
|
Object |
invoke(String name,
Map<String,Object> kwargs)
Invokes a callable function with a named arguments given by the dictionary kwargs.
|
Object |
invoke(String name,
Object... args)
Invokes a callable function with a variable number of arguments args.
|
Object |
invoke(String name,
Object[] args,
Map<String,Object> kwargs)
Invokes a callable function with a variable number of arguments args and a named arguments
given by the dictionary kwargs.
|
Object |
invokeMethod(String obj,
String name,
Object... args)
Invokes the method of a called object with a variable number of arguments args.
|
void |
set(String name,
Object value)
Sets the Java Object into the interpreter's global scope with the specified variable name.
|
public PythonInterpreter(PythonInterpreterConfig config)
config - the PythonInterpreterConfig object for constructing a Python Interpreter.public void set(String name, Object value)
Interpreterset in interface Interpretername - the variable namevalue - the variable valuepublic Object get(String name)
Interpreterget in interface Interpretername - the variable namepublic <T> T get(String name, Class<T> clazz)
Interpreterget in interface Interpretername - the variable nameclazz - the corresponding Java Class of the value.public Object invoke(String name, Object... args)
Interpreterinvoke in interface Interpretername - the function nameargs - the variable number of argumentspublic Object invoke(String name, Map<String,Object> kwargs)
Interpreterinvoke in interface Interpretername - the function namekwargs - the named argumentspublic Object invoke(String name, Object[] args, Map<String,Object> kwargs)
Interpreterinvoke in interface Interpretername - the function nameargs - the variable number of argumentskwargs - the named argumentspublic Object invokeMethod(String obj, String name, Object... args)
InterpreterinvokeMethod in interface Interpreterobj - the called objectname - the name of the methodargs - the variable number of argumentspublic void exec(String str)
Interpreterexec in interface Interpreterpublic void close()
close in interface AutoCloseableCopyright © 2022–2025. All rights reserved.