update a list element using an element in another list

Daiyue Weng daiyueweng at gmail.com
Tue Jan 31 06:28:45 EST 2017

Hi, I am trying to update a list of dictionaries using another list of
dictionaries correspondingly. In that, for example,

#  the list of dicts that need to be updated
dicts_1 = [{'dict_1': '1'}, {'dict_2': '2'}, {'dict_3': '3'}]

# dict used to update dicts_1
update_dicts = [{'dict_1': '1_1'}, {'dict_2': '1_2'}, {'dict_3': '1_3'}]

so that after updating,

dicts_1 = [{'dict_1': '1_1'}, {'dict_2': '1_2'}, {'dict_3': '1_3'}]

what's the best way to the updates?

This is actually coming from when I tried to create a list of entities
(dictionaries), then updating the entities using another list dictionaries
using google.cloud.datastore.

entities = [Entity(self.client.key(kind, entity_id)) for entity_id in

# update entities using update_dicts
for j in range(len(entities)):
for i in range(len(update_dicts)):
if j == i:

I am wondering is there a brief way to do this.


More information about the Python-list mailing list