Think of it more like indexing a range. Say you have: L[:] = M[:]
Which is the same as: L[0:len(L)] = M[0:len(M)] Which mentally you can think of like: L[0], L[1],...L[len(L)] = M[0],M[1],...M[len(M)] Slicing is just indexing that represents more than one element, and if you think about it like that slice assignment makes much more sense. -- Ryan https://refi64.com/ On Jun 5, 2019, 2:56 AM -0500, Yanghao Hua <yanghao...@gmail.com>, wrote: > On Tue, Jun 4, 2019 at 12:47 PM Jeroen Demeyer <j.deme...@ugent.be> 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. > > > > 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[:] = new_list > > > > would become > > > > L <== new_list > > The part I liked it is, with <== basically all kinds of unnecessary > details has been hidden from users. > > For example, L[:] if appeared at the right hand side, means a copy > (not a reference) of L, but now when appear on the left hand side, it > behaves like an in-place copy. This two isn't it mentally > contradicting each other? > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s > Code of Conduct: http://python.org/psf/codeofconduct/
Python-Ideas mailing list -- python-dev(a)python.org To unsubscribe send an email to python-ideas-leave(a)python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/