Raymond Hettinger <[email protected]> added the comment:
> In Python, the plus operator for sequences (strings, lists,
> tuples) is non-commutative.
For sequences, that is obvious and expected, but not so much with mappings
where the order of overlapping keys is determined by the left operand and the
value associated with those keys is determined by the right operand.
Also with sequences the + operator actually means "add to", but with
dictionaries it means "add/or replace" which is contrary to the normal meaning
of plus. I think that was one of Guido's reasons for favoring "|" instead of
"+" for set-to-set operations.
> We already have a syntax for dict merging: {**d1, **d2}.
> It works with arbitrary mappings,
This is a good point.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue36144>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com