Getting values from python interpreter from Java

Alex Martelli aleax at
Sat Apr 26 01:52:46 CEST 2003

<posted & mailed>

Lichtenstein, Mark (Contractor) wrote:

> I would like to see how to get the value of a local variable from Java.
> In Java, I am saving the values of the local dictionary in a PyObject Java
> object.
> Using a PythonInterpreter object called "interp", I use setLocals and
> getLocals methods to
> get and restore the local dictionary.
> interp.setLocals(localsObject);
> interp.getLocals(localsObject);
> My question is from Java how does someone go into the PyObject contatining
> the locals dictionary to get the value of a local dictionary variable?

As I already answered on python-help, you can get the PyObject value
of a variable by calling localsObject.__getitem__("varname") from Java.

Please don't post questions to python-help AND the general Python
list too, choose just one or the other, thanks.


More information about the Python-list mailing list