permaculture playing cards*
The moose likes Jython/Python and the fly likes Python dict() to Jython in eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Jython/Python
Bookmark "Python dict() to Jython in eclipse" Watch "Python dict() to Jython in eclipse" New topic
Author

Python dict() to Jython in eclipse

lee fair
Greenhorn

Joined: Jun 12, 2012
Posts: 1
Does anyone know a simple solution to converting python dict() to jython in eclipse?
I just want to index two pre-existing lists. List of names, list of values), names[0] = values[0] that sort of thing.

Thanks
karthik raghunathan
Greenhorn

Joined: Nov 12, 2011
Posts: 10
the following works in Jython - do I understand the question correctly ?

>>> dict({1:2})
{1: 2}
Palak Mathur
Ranch Hand

Joined: Jan 29, 2007
Posts: 313

I am still confused, what exactly is the problem?


Palak Mathur | My Blog | TechJaunt | What is JavaRanch? | List of All FAQs
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4167
    
  21

lee fair wrote:I just want to index two pre-existing lists. List of names, list of values), names[0] = values[0] that sort of thing.

Thanks


That seems like zip() not dict():



The output is:
('1', 'one')
('2', 'two')
('3', '3')

So zip makes a List of tuples, indexing each list passed in equally. If you wanted to turn that into a dictionary you do:


which gives me:
{'1': 'one', '3': '3', '2': 'two'}

I am working Python, not Jython, so what of that is what you want, and what is not working?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Python dict() to Jython in eclipse
 
Similar Threads
Jython ? what for ?
Jython
Some Groovy vs Python observations.
To the author, Mr. Bill
Jython: os.chdir()