[Python-ideas] PEP: Dict addition and subtraction

James Lu jamtlu at gmail.com
Thu Mar 7 18:29:26 EST 2019


Now, this belongs as a separate PEP, and I probably will write one, but I propose:

d1 << d2 makes a copy of d1 and merges d2 into it, and when the keys conflict, d2 takes priority. (Works like copy/update.)

d1 + d2 makes a new dictionary, taking keys from d1 and d2. If d1 and d2 have a different value for same key, a KeyError is thrown. 






More information about the Python-ideas mailing list