Parsing Python dictionary with multiple objects

Rustom Mody rustompmody at gmail.com
Wed Oct 15 18:43:06 CEST 2014


On Wednesday, October 15, 2014 9:58:49 PM UTC+5:30, Anurag Patibandla wrote:
> First the values printed by
> '[(queues[j], json.get(queues[j])) for j in range(len(queues))] '
> is a list, so I tried to convert it into a dict using dict().
> And then I tried doing dict[0] but there is an error which says:
> 'type' object has no attribute '__getitem__'

print each step in the process until the error step

Also assuming

[(queues[j], json.get(queues[j])) for j in range(len(queues))]

is the same as

[(q, json.get(q) for q in queues]

do

a = [(q, json.get(q) for q in queues]
print a
b = dict(a)
print b
c = b[0]
print c

or whatever it is you are doing

and PASTE (not NARRATE) the results



More information about the Python-list mailing list