public class PyCallable extends PyObject
Instance Method Example:
jep.eval("class Example(object):\n" +
" def __init__(self):\n" +
" pass\n" +
" def helloWorld(self):\n" +
" return 'Hello World'\n");
jep.eval("instance = Example()");
PyObject pyobj = jep.getValue("instance", PyObject.class);
PyCallable pyHelloWorld = PyObject.getAttr("helloWorld", PyCallable.class);
String result = (String) pyHelloWorld.call();
Function Example:
jep.eval("def hello(arg):\n" +
" return 'Hello ' + str(arg)");
PyCallable pyHello = jep.getValue("hello", PyCallable.class);
String result = (String) pyHello.call("World");
Constructor and Description |
---|
PyCallable(long tstate,
long pyObject,
Jep jep) |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
call(java.util.Map<java.lang.String,java.lang.Object> kwargs)
Invokes this callable with keyword args.
|
java.lang.Object |
call(java.lang.Object... args)
Invokes this callable with the args in order.
|
java.lang.Object |
call(java.lang.Object[] args,
java.util.Map<java.lang.String,java.lang.Object> kwargs)
Invokes this callable with positional args and keyword args.
|
public PyCallable(long tstate, long pyObject, Jep jep) throws JepException
JepException
public java.lang.Object call(java.lang.Object... args) throws JepException
args
- args to pass to the function in orderObject
valueJepException
- if an error occurspublic java.lang.Object call(java.util.Map<java.lang.String,java.lang.Object> kwargs) throws JepException
kwargs
- a Map of keyword argsObject
valueJepException
- if an error occurspublic java.lang.Object call(java.lang.Object[] args, java.util.Map<java.lang.String,java.lang.Object> kwargs) throws JepException
args
- args to pass to the function in orderkwargs
- a Map of keyword argsObject
valueJepException
- if an error occurs