python OrderedDict update a list of keys with the same value -


i trying update list of keys ordereddict same int value, like

for idx in indexes:     res_dict[idx] = value 

where value int variable, indexes list of ints, act keys, res_dict ordereddict, tried resolve above in 1 line,

res_dict[indexes]=value 

but got error:

typeerror: unhashable type: 'list' 

is loop or list comprehension way(s) update here?

the ordereddict (and dict well) provide method update update multiple values @ once.

the pythonic manner want :

res_dict.update((idx, value) idx in indexes) 

it keep original order of ordereddict.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -