[Python-ideas] The @update operator for dictionaries
rosuav at gmail.com
Sat Mar 9 11:51:49 EST 2019
On Sun, Mar 10, 2019 at 3:46 AM Jonathan Fine <jfine2358 at gmail.com> wrote:
> Chris Angelico suggested that
> a = a.update_with(b)
> would be better than
> a @update= b
> One of the key points of += is that
> parent.child['toy'].wheel.speed += 1
> increases the speed that that wheel by 1, without having to write
> parent.child['toy'].wheel.speed = parent.child['toy'].wheel.speed + 1
> To answer Chris's other points. It not me, but Chris and Steve who
> want to bind dict.update to an operator, namely '+'. I'm suggested
> that if you do that, why not call the operator 'update'.
> Finally, we don't yet have any real idea how much difficulty the
> grammar change would cause.
No, we don't, because you have yet to say what the grammar change would BE.
Changing language grammar is a big deal. You don't just say "oh, we
should do this, and hey, it's gonna break code". Steven's proposal
(not mine, btw, unless you meant some other Chris?) involves giving
meaning to "x + y" for different values of x and y, but doesn't change
the grammar at all. If you're proposing a completely new meaning for
completely new syntax, *be clear* about what you are proposing.
More information about the Python-ideas