| 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: 7
|
|
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: 303
|
|
|
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: 3026
|
|
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?
|
 |
 |
|
|
subject: Python dict() to Jython in eclipse
|
|
|