Just Launched: You can now import projects and releases from Google Code onto SourceForge
We are excited to release new functionality to enable a 1-click import from Google Code onto the Allura platform on SourceForge. You can import tickets, wikis, source, releases, and more with a few simple steps. Read More
Digging around in the archives, I ran across a brief
discussion concerning the coercion of python
dictionaries into Java Maps. I couldn't see much of a
My specific problem is that I need to embed a python
script into my application, which will populate a
dictionary, which will then be extracted from the
python runtime and passed back to the business logic.
I've tried two approaches:
(1) Create the dictionary within the script, then try
PythonInterpreter.get(name, class) to extract it.
(2) Create the Map within Java, use
PythonInterpreter.set(name,value), have the script
populate it, then pass it back.
Now, the first approach fails because I can't coerce
the dictionary into any standard java type, and the
second approach fails because the Map is being cloned
when I pass it into the Interpreter, so my original
reference to the Map is useless.
The Map in question is guaranteed to be
String->String, so that might simply things.
Can anyone suggest a simple, workable solution?
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
From: Michel Pelletier <michel@di...> - 2002-04-12 09:47:44
On Friday 12 April 2002 11:22 am, Kenny MacLeod wrote:
> Digging around in the archives, I ran across a brief
> discussion concerning the coercion of python
> dictionaries into Java Maps. I couldn't see much of a
> resolution, however.
> My specific problem is that I need to embed a python
> script into my application, which will populate a
> dictionary, which will then be extracted from the
> python runtime and passed back to the business logic.
Why not populate a Map in Python instead of a dictionary?
>>> x = java.util.WeakHashMap()
>>> x = 6
You can probably use your existing python code with little modification to
support a Map instead of a dict.