[Python-ideas] Have dict().update() return its own reference.
Masklinn
masklinn at masklinn.net
Fri Apr 20 14:47:34 CEST 2012
On 2012-04-20, at 14:37 , Xavier Ho wrote:
> Thanks, that's fair, for consistency.
>
> One use case for my question was a stackoverflow question regarding merging
> two dict's. If update() returned its own reference, and if we explicitly
> wanted a copy (instead of an in-place modification), we could have used
>
> dict(x).update(y)
>
> given x and y are both dict() instances.
If you start from dict instances, you could always use:
merged = dict(x, **y)
More information about the Python-ideas
mailing list