On Thu, Jun 6, 2019 at 9:48 AM Chris Angelico <ros...@gmail.com> wrote:
> 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".

Alright Chris, I would rephrase it like this: they are different
because one of them represent the original list (when at the left hand
side), and the other represent a new list (when at the right hand
side). Whether or not they are "completely different" is a subjective
matter and I will not enforce it. For me, they are really different.

I think the trick it used here is: let's sacrifice a little bit of
low-level consistency, as normally nobody would use list slicing
(which always means a copy on right hand side) on the left hand side,
so let's redefine it to mean in-place modification. And descriptor and
left hand slicing is probably the only two exceptions where an
assignment (=) can actually change things in place (you see, this is
really an exceptional case for =). And it will become more confusing
if L[:] := thing is used, it is now an expression which kind of let
you think about "right hand side" (e.g. what about z = (L[:] :=
[7,8,9,10])). L[:] := thing currently does not work in python3.8a3,
throws a "Syntax Error: cannot use named assignment with subscript".
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/

Reply via email to