[Tutor] the "**" operator?
Hugo Arts
hugo.yoshi at gmail.com
Sat Dec 11 01:55:05 CET 2010
On Sat, Dec 11, 2010 at 1:26 AM, Alex Hall <mehgcap at gmail.com> wrote:
> Thanks all! I thought update() would add an item even if it would be a
> duplicate, but apparently not. I also now better understand why I am
> always passing around *args and **kwargs when calling super(). Very
> interesting...
>
Actually, it does. If a key is already present, the value will be
overwritten (since you can't have a key with more than one value,
obviously).
If you don't want to overwrite the duplicates, filter them
some_dict.update(x for x in additional_dict.items() if x[0] not in some_dict)
More information about the Tutor
mailing list