Issue 9705: limit dict.update() to a given list of keys (original) (raw)

Issue9705

Created on 2010-08-28 17:00 by Ultrasick, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg115157 - (view) Author: (Ultrasick) Date: 2010-08-28 17:00
my_dict_1 = {'a' : 1, 'b' : 1} my_dict_2 = {'a' : 2, 'b' : 2, 'c' : 2} my_dict_1.update(my_dict_2, ['a', 'c']) should result for my_dict_1: {'a' : 2, 'b' : 1, 'c' : 2}
msg115160 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-08-28 17:31
Please post to python-ideas first, and note a moratorium on builtin changes is inplace.
msg115167 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-08-28 20:02
FWIW, the usual way to spell this in Python is: my_dict_1.update((k, my_dict_2[k]) for k in ['a', 'c']) We try to keep filtering operations separate from map/fold operations for orthognality.
History
Date User Action Args
2022-04-11 14:57:05 admin set github: 53914
2010-08-28 20:02:50 rhettinger set nosy: + rhettingermessages: +
2010-08-28 17:31:09 benjamin.peterson set status: open -> closednosy: + benjamin.petersonmessages: + resolution: rejected
2010-08-28 17:00:55 Ultrasick create