On Thu, Jun 6, 2019 at 5:40 PM Yanghao Hua <yanghao...@gmail.com> wrote: > > On Thu, Jun 6, 2019 at 6:31 AM Ryan Gonzalez <rym...@gmail.com> wrote: > > > > 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. > > This makes definitely sense on its own right. Problem is, when it > moves to the right hand side, it means exactly the opposite: instead > of indexing the full range of L, it is now representing a copy of L (X > = L[:]).
Come again? It's still indexing the full range of L - that's not "exactly the opposite"! > So L[:] = thing vs thing = L[:], although in both assignment > L shows up exactly the same: L[:], but means completely different > things. They have a difference for the built-in list type in that slicing a list returns a new list with references to the same objects, thus "x = x[:]" is going to give you an equivalent but distinct list. That's an important point in some contexts, but it's by no means "completely different". ChrisA 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/