public class Python extends Object
Interface to Python.
Unless otherwise specified, all methods in this class throw PyException
on failure.
Modifier and Type | Class and Description |
---|---|
static class |
Python.Platform
Provides information needed to start Python.
|
Modifier and Type | Method and Description |
---|---|
PyObject |
getBuiltins()
Returns the
builtins module, which contains Python’s built-in functions (e.g. |
static Python |
getInstance()
Gets the interface to Python.
|
PyObject |
getModule(String name)
Returns the module with the given name.
|
static Python.Platform |
getPlatform()
Returns the Platform object which was used to start Python, or
null if Python has not yet been started. |
static boolean |
isStarted()
Return whether the Python virtual machine is running
|
static void |
start(Python.Platform platform)
Starts the Python virtual machine.
|
public PyObject getBuiltins()
Returns the builtins
module, which contains Python’s built-in functions (e.g. open
), types (e.g. dict
), constants (e.g. True
) and exceptions (e.g. ValueError
).
public static Python getInstance()
Gets the interface to Python. This method always returns the same object. If start()
has not yet been called, it will be called with a new GenericPlatform
.
public PyObject getModule(String name)
Returns the module with the given name. Dot notation may be used to get submodules (e.g. os.path
).
public static Python.Platform getPlatform()
Returns the Platform object which was used to start Python, or null
if Python has not yet been started.
public static boolean isStarted()
Return whether the Python virtual machine is running
public static void start(Python.Platform platform)
Starts the Python virtual machine. If this method is called, it can only be called once, and it must be before any call to getInstance()
.
If running on Android, see the notes here on how to call this method in an app. If running on any other platform, there’s no need to call this method, unless you want to customize the Python startup process.