org.python.util
public class PythonInterpreter extends Object
Version: 1.0, 02/23/97
Constructor Summary | |
---|---|
PythonInterpreter()
Create a new Interpreter with an empty dictionary | |
PythonInterpreter(PyObject dict)
Create a new interpreter with the given dictionary to use as its
namespace
| |
PythonInterpreter(PyObject dict, PySystemState systemState) |
Method Summary | |
---|---|
void | cleanup() |
PyObject | eval(String s)
Evaluate a string as Python source and return the result
|
void | exec(String s)
Execute a string of Python source in the local namespace
|
void | exec(PyObject code)
Execute a Python code object in the local namespace
|
void | execfile(String s)
Execute a file of Python source in the local namespace
|
void | execfile(InputStream s) |
void | execfile(InputStream s, String name) |
PyObject | get(String name)
Get the value of a variable in the local namespace
|
Object | get(String name, Class javaclass)
Get the value of a variable in the local namespace Value will be
returned as an instance of the given Java class.
|
PyObject | getLocals() |
static void | initialize(Properties preProperties, Properties postProperties, String[] argv)
Initializes the jython runtime. |
void | set(String name, Object value)
Set a variable in the local namespace
|
void | set(String name, PyObject value)
Set a variable in the local namespace
|
void | setErr(PyObject outStream) |
void | setErr(Writer outStream) |
void | setErr(OutputStream outStream) |
void | setLocals(PyObject d) |
void | setOut(PyObject outStream)
Set the Python object to use for the standard output stream
|
void | setOut(Writer outStream)
Set a java.io.Writer to use for the standard output stream
|
void | setOut(OutputStream outStream)
Set a java.io.OutputStream to use for the standard output stream
|
Parameters: dict the dictionary to use
Parameters: s the string to evaluate
Parameters: s the string to execute
Parameters: code the code object to execute
Parameters: s the name of the file to execute
Parameters: name the name of the variable
interp.get("foo", Object.class)
will return the most
appropriate generic Java object.
Parameters: name the name of the variable javaclass the class of object to return
Parameters: preProperties A set of properties. Typically System.getProperties() is used. postProperties An other set of properties. Values like python.home, python.path and all other values from the registry files can be added to this property set. PostProperties will override system properties and registry properties. argv Command line argument. These values will assigned to sys.argv.
Parameters: name the name of the variable value the value to set the variable to. Will be automatically converted to an appropriate Python object.
Parameters: name the name of the variable value the value to set the variable to
Parameters: outStream Python file-like object to use as output stream
Parameters: outStream Writer to use as output stream
Parameters: outStream OutputStream to use as output stream