+1 on this, it seems very natural to me.
I don’t mean to downplay the concerns people have, but in my experience teaching newbies, dictionaries take some time to wrap their heads around anyway. So yes, they may be confused when + removes data, but they’d be confused anyway :-)
And it would be less confusing than:
{**d1, **d2}
That means pretty much nothing to a newbie, and even if they do get what ** means, it’s still some version of “put the contents of these two ducts together” — I can’t see how that is any less confusing than d1+d2.
As for expecting it to be lossless like list addition — if you don’t understand that ducts can’t have duplicate keys, you’re don’t “get” dicts anyway.
>> The problem is that dicts are complex objects with two pieces of
>> information,
And they are with or without +, of course.
> Even better, if we had two engineers (key) named Anita and Carolyn (values) and combined them into a group, do you expect one of them to vanish?
Then a dict is not the data structure in which to store this data, plain and simple.
You don’t use a key like “engineer” if you might have more than one engineer!
This is completely independent of syntax.
-CHB
--
Christopher Barker, PhD
Python Language Consulting
- Teaching
- Scientific Software Development
- Desktop GUI and Web Development
- wxPython, numpy, scipy, Cython
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@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/2LDA5UFD5M273SE2WOWWUHLZWJX5N3LC/
Code of Conduct: http://python.org/psf/codeofconduct/