[Python-ideas] Assign-in-place operator

2019-06-04 Thread Stephen J. Turnbull
Jeroen Demeyer writes: > When you think of it this way, it's not an unreasonable request. There > would be at least one major use of this operator within CPython, for > lists. With this proposal, the awkward syntax (there are 219 instances > of this in the CPython sources) > >L[:] =

Re: [Python-ideas] Assign-in-place operator

2019-06-04 Thread Terry Reedy
On 6/4/2019 6:47 AM, Jeroen Demeyer wrote: I'd like to get rid of all the signal and HDL stuff (whatever that means) in this thread, so I think what the original poster really wants is an "assign in place" operator. Basically, something like += or *= but without the arithmetic. I believe that

Re: [Python-ideas] Assign-in-place operator

2019-06-04 Thread Ricky Teachey
Ok agreed on .update and .extend. Two operators (+= and <==) doing the same thing is dumb. And for .append I agree "this thing is the same, just add this thing" is a little at odds with "update this thing when i send this other thing into it". > my_gen.send > > Sure, this makes sense to me! > I

Re: [Python-ideas] Assign-in-place operator

2019-06-04 Thread Jeroen Demeyer
On 2019-06-04 14:34, Ricky Teachey wrote: "update an object with another" (dunder update) Yes, that's essentially what I meant. To me, "assign an object in place" and "update an object with another" mean the same thing. A few come to mind: my_dict.update This is PEP 584, where += is used

Re: [Python-ideas] Assign-in-place operator

2019-06-04 Thread Ricky Teachey
I agree this needs to be reframed but suggest that assignment in place isn't the most useful mental model. Instead, something like "generically apply a value to another" (dunder apply) or "update an object with another" (dunder update) might have a prayer of making sense. Perhaps there are other s

Re: [Python-ideas] Assign-in-place operator

2019-06-04 Thread Paul Moore
On Tue, 4 Jun 2019 at 12:47, Jeroen Demeyer wrote: > > On 2019-06-04 13:29, Steven D'Aprano wrote:> As far as I can tell, there > is no difference between your proposal > > and the OP's proposal except you have changed the name of the dunder > > from __arrow__ to __iassign__. > > I never claimed t

Re: [Python-ideas] Assign-in-place operator

2019-06-04 Thread Jeroen Demeyer
On 2019-06-04 13:29, Steven D'Aprano wrote:> As far as I can tell, there is no difference between your proposal and the OP's proposal except you have changed the name of the dunder from __arrow__ to __iassign__. I never claimed that there was a difference. I just tried to clarify what the orig

Re: [Python-ideas] Assign-in-place operator

2019-06-04 Thread Steven D'Aprano
On Tue, Jun 04, 2019 at 12:47:30PM +0200, Jeroen Demeyer wrote: > When you think of it this way, it's not an unreasonable request. There > would be at least one major use of this operator within CPython, for > lists. With this proposal, the awkward syntax (there are 219 instances > of this in t

[Python-ideas] Assign-in-place operator

2019-06-04 Thread Jeroen Demeyer
I'd like to get rid of all the signal and HDL stuff (whatever that means) in this thread, so I think what the original poster really wants is an "assign in place" operator. Basically, something like += or *= but without the arithmetic. When you think of it this way, it's not an unreasonable re