[Python-ideas] Adding "+" and "+=" operators to dict
Donald Stufft
donald at stufft.io
Fri Feb 13 00:47:13 CET 2015
More information about the Python-ideas mailing list
Fri Feb 13 00:47:13 CET 2015
- Previous message: [Python-ideas] Adding "+" and "+=" operators to dict
- Next message: [Python-ideas] Adding "+" and "+=" operators to dict
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> On Feb 12, 2015, at 6:43 PM, Eric Snow <ericsnowcurrently at gmail.com> wrote: > > On Thu, Feb 12, 2015 at 3:43 AM, Steven D'Aprano <steve at pearwood.info> wrote: >> A very strong -1 on the proposal. We already have a perfectly good way >> to spell dict += , namely dict.update. As for dict + on its own, we have >> a way to spell that too: exactly as you write above. > > From what I understand, the whole point of "d + d" (or "d | d") is as > an alternative to the PEP 448 proposal of allowing multiple keyword > arg unpacking clauses ("**") in function calls. So instead of "f(**a, > **b)" it would be "f(**a+b)" (or "f(**a|b)"). However, the upside to > the PEP 448 syntax is that merging could be done without requiring an > additional intermediate dict. Personally, I'd rather have the syntax > than the operator (particularly since it would apply to the dict > constructor as well: "dict(**a, **b, **c)”) That’s one potential use case but it can be used in a lot more situations than just that one. Hence why I said in that thread that being able to merge dictionaries is a much more general construct than only being able to merge dictionaries inside of a function call. --- 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/4b095d9c/attachment.sig>
- Previous message: [Python-ideas] Adding "+" and "+=" operators to dict
- Next message: [Python-ideas] Adding "+" and "+=" operators to dict
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list