public class PyModule extends PyObject
Modifier and Type | Method and Description |
---|---|
<T> T |
createProxy(Class<T> type)
Create a Java proxy instance of this Python module which contains compatible functions to the ones provided in the
interface given by the
type parameter. |
static PyObject |
extendSysPath(String modulePath,
boolean prepend)
Extends Python's 'sys.path' variable by the given module path.
|
static PyModule |
getBuiltins()
Get the Python interpreter's buildins module and returns its Java representation.
|
static PyModule |
getMain()
Get the Python interpreter's main module and return its Java representation.
|
String |
getName() |
static PyModule |
importModule(String name)
Import a Python module into the Python interpreter and return its Java representation.
|
asDict, asList, call, call, call, call, call, callMethod, cleanup, close, createProxy, delAttribute, eq, equals, executeCode, executeCode, executeScript, executeScript, getAttribute, getAttribute, getBooleanValue, getDoubleValue, getIntValue, getLongValue, getObjectArrayValue, getObjectValue, getPointer, getStringValue, getType, hasAttribute, hash, hashCode, isBoolean, isCallable, isConvertible, isDict, isFloat, isFunction, isInt, isList, isLong, isModule, isNone, isString, isTuple, repr, setAttribute, setAttribute, str, toString, unwrapProxy
public String getName()
public static PyModule getMain()
PyLib.execScript("def incByOne(x): return x + 1"); PyModule mainModule = PyModule.getMain(); PyObject eleven = mainModule.call("incByOne", 10);
public static PyModule getBuiltins()
len()
, type()
, list()
, etc. For example:
builtins = PyModule.getBuiltins(); PyObject size = builtins.call("len", pyList);
PyObject.call(String, Object...)
public static PyModule importModule(String name)
name
- The Python module's name.public static PyObject extendSysPath(String modulePath, boolean prepend)
modulePath
- The new module path. Should be an absolute pathname.prepend
- If true, the new path will be the new first element of 'sys.path', otherwise it will be the last.public <T> T createProxy(Class<T> type)
type
parameter.createProxy
in class PyObject
T
- The interface name.type
- The interface's type.Copyright © 2014–2022 Brockmann Consult GmbH. All rights reserved.