[Python-ideas] Joining dicts again
Steven D'Aprano
steve at pearwood.info
Sun Feb 23 15:08:58 CET 2014
On Sun, Feb 23, 2014 at 02:31:27PM +0100, haael at interia.pl wrote:
>
> @Steven D'Aprano
>
> > So we have *at least* four different ways to merge dictionaries a and b:
[...]
> > The question is, why should any one of these be picked out as so
> > obviously more useful than the others as to deserve being a dict method
> > or operator support?
Please note the question. That is a critical question.
> I would really like to have a simple dict joining _expression_ that
> can be inserted everywhere I just need.
But which one? There are at least four "simple dict joining" operations.
Which one should be turned into a method, and which ones should be left
out? It's easy to say that you want a dict operator | to merge
dictionaries, but you still have to explain why one merge function
should be promoted to an operator, and the others three (or more) merge
functions miss out. Then, when people complain that *their* choice got
left out, you can explain why their use-case is not important enough to
be an operator, but yours is.
In the meantime, you can add a two or three line function to your
module, and use that. An easy solution to a simple problem.
--
Steven
More information about the Python-ideas
mailing list