java.util.map Compatible data structure in python

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Heshan Suri
    New Member
    • Apr 2008
    • 6

    java.util.map Compatible data structure in python

    I am using java.util.map to store some data ( one key and two values , per row ) in java and return it to a python function . What kind of a data structre should I use in python to catch it? (btw I am using Jython as a bridge between python and java)
  • jlm699
    Contributor
    • Jul 2007
    • 314

    #2
    You can do a dictionary of lists to emulate a map:
    [code=python]
    >>> md = {}
    >>> md['val1'] = ['keya', 'keyb']
    >>> md['val2'] = ['keyc', 'keyd']
    >>> for elem in md:
    ... print "The key is", elem, "and the values of this key are:", md[elem]
    ...
    The key is val2 and the values of this key are: ['keyc', 'keyd']
    The key is val1 and the values of this key are: ['keya', 'keyb']
    >>> [/code]

    Comment

    Working...