[Tutor] When is = a copy and when is it an alias
Danny Yoo
dyoo at hashcollision.org
Mon Jan 27 20:01:56 CET 2014
> Apparently a[0]=b[0] does not qualify as "symbolic assignment" in this case.
> a[0] is not a reference to b[0]. I think I see the essential distinction.
> Experience will complete the picture for me.
Yes. The distinction is something that is blurred by Python's syntax.
The "=" is a conceptually different thing, based on what's on the
"left hand side" of the "=". It can means "variable binding" or
"structure mutation", and those concepts are similar, but not the same
thing. And variable binding itself can even have a slightly
different meaning, depending on whether the surrounding context is a
function definition or not, establishing a local or global variable
binding. Whew!
Assignment can be tricky. It's at the heart of one of the things that
makes programming "hard": it is very much about change, about
dynamics, about having to reason what the world looks like "before"
and "after" a change.
(And hence why some customized programming languages for beginners
outright prohibit the assignment operator.)
More information about the Tutor
mailing list