27 Feb 2019 27 Feb '19
On 2019-02-27 17:37, Guido van Rossum wrote:
On Wed, Feb 27, 2019 at 9:34 AM George Castillo <email@example.com mailto:firstname.lastname@example.org> wrote:
The key conundrum that needs to be solved is what to do for `d1 + d2` when there are overlapping keys. I propose to make d2 win in this case, which is what happens in `d1.update(d2)` anyways. If you want it the other way, simply write `d2 + d1`. This would mean that addition, at least in this particular instance, is not a commutative operation. Are there other places in Python where this is the case?
Yes there are. 'a' + 'b' is not the same as 'b' + 'a'.
For non-numbers we only require + to be associative, i.e. a + b + c == (a + b) + c == a + (b + c).
That is satisfied for this proposal. Are there any advantages of using '+' over '|'?