PythonAdapter

public class PythonAdapter

Adapter of a PyObject that offers some shortcut methods for invoking etc. Motivation: The Jython API is not as elegant as would be desirable. However, with proper understanding of PyObject, this class would not be necessary.

Author:pipek

Fields

pyObject

protected PyObject pyObject

Constructors

PythonAdapter

public PythonAdapter(PyObject object)

Methods

getAttribute

public PyObject getAttribute(String name)

Get the attribute of PyObject.

Parameters:
  • name – Name of the attribute.
Returns:

The attribute as PyObject or null (if attribute not present).

getPythonObject

public PyObject getPythonObject()

Get the unwrapped PyObject.

hasAttribute

public boolean hasAttribute(String name)

invoke

public PyObject invoke(String method, Map<String, PyObject> parameters)

Call a method on PyObject with parameters.

invoke

public PyObject invoke(String method)

Call a method on PyObject without parameters.

Parameters:
  • method – Name of the method (callable attribute) to call on the object.
Returns:

Result of the call as PyObject