> >> but i'm -0 because i am very concerned it will not be obvious to new
> >> learners, without constantly looking it up, whether adding two mappings
> >> together would either:
> >
> > When Python first added the dict.update method (I think that was in
> > 1.5?) I could never remember if it kept the old values or the new. But
> > there were a million other things I couldn't remember either, such as
> > whether slicing was open or closed, whether the trig functions in math
> > took degrees or radians, whether exponentiation was ^ or ** and whether
> > I needed parentheses around calls to print or not.
>
> Agreed.... we already have update; people already have to learn that it
> uses the right value, and that it’s spelled update rather than merge! or
> something else. If we have + or |, people will have to learn that it uses
> the right value there too. The fact that all of the operations are
> consistent will mean that eventually they only have one thing to remember
> instead of a bunch of separate things, but it’s still a thing to remember.
>

Well, the part about looking it up wasn't so much the actual objection as
it being so much less intuitive- for newcomers- what exactly the operation
would do compared to the addition of the other basic structures: strings
and lists. Those are so obvious they just make sense. Having to look it up
a lot is just a potential symptom of a larger problem.

Granted, I'm coming at this from an assumption that there should be a
higher bar for operators as compared to methods: imo, they should be
totally intuitive in the way they behave. In fact this consistency about
operators is one of the things I love about python. I don't think that
standard is ~quite~ met here. So I'm still -0.. I think the most intuitive
situation is the status quo: "no dict addition because what do you do with
the values?" It's certainly possible I'm setting the bar too high, though,
or that I'm so familiar with the way operators for other structures behave
now that they seem intuitive to me when really they are not.

The .update() method, on the other hand, feels much more naturally
intuitive once you are aware it exists. And I would be very much in favor
of a method (a new one, or perhaps adding arguments to .copy()) that copies
and updates a dictionary in a single step.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/BOL525ZPR2BSZ632H54UPO7JYO4CCUEL/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to