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 module
__builtin__ in Python 2 or builtins in Python 3. |
static Python |
getInstance()
Gets the interface to Python.
|
PyObject |
getModule(String name)
Returns the module with the given absolute name.
|
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 module __builtin__
in Python 2 or builtins
in Python 3. This module 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 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.