|
From: David H. <dav...@gm...> - 2008-04-25 15:12:09
|
On Fri, Apr 25, 2008 at 4:47 AM, Heshan Suriyaarachchi
<hes...@gm...> wrote:
> Hi,
> I am trying to execute the below java code.But when I try to assign the
> dictionary to map it gives an classcast exception as below
>
> Exception in thread "main" java.lang.ClassCastException:
> org.python.core.PyDictionary cannot be cast to java.util.Map
Correct; Jython does not automatically convert the dict to a Map or
automatically provide a Map facade. For interoperation between Python
and Java, you will have to do the conversion yourself, or use HashMap
for any map object that might be returned to Java code. For example:
from java.util import HashMap
# myfile.py
# method which returns a Dictionary
def getDictionary():
Dictionary2 = HashMap()
etc.
-David
|