[Python-ideas] Adding "+" and "+=" operators to dict

Donald Stufft donald at stufft.io
Fri Feb 13 00:29:47 CET 2015


> On Feb 12, 2015, at 6:28 PM, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> 
> On Thu, Feb 12, 2015 at 5:25 AM, Donald Stufft <donald at stufft.io> wrote:
>> I’ve wanted this several times, explicitly the copying variant of it. I always
>> get slightly annoyed whenever I have to manually spell out the copy and the
>> update.
> 
> copy-and-update:
> 
>  dict(old_dict, **other_dict)
> 

Only works if other_dict’s keys are all valid keyword arguments and AFAIK is considered an implementation detail of CPython.

---
Donald Stufft
PGP: 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150212/7e2e49a7/attachment.sig>


More information about the Python-ideas mailing list