[Tutor] Is there any logic in this?
Kent Johnson
kent37 at tds.net
Sat Sep 1 17:36:16 CEST 2007
jim stockford wrote:
> seems to me this is an artifact of the language.
'artifact of the language' to me implies some sort of unintended
consequence. In fact it is fundamental to the way assignment works in
Python.
This is good reading:
http://tinyurl.com/ysz8sr
> reading right to left:
> "make a list that contains 10,40,30,20, then create a
> name 'a' to be used as a label to identify that list, then
> (next line) create a label 'b' to attach to whatever is
> the thing 'a' refers to, then (next line) modify the thing
> via 'b' (e.g. b.sort)."
Yes
> the effect is programmers have to know this is the
> case. those who have the old style "C head" using the
> model of a variable name representing an area in
> memory where assignment copies data to a new area
> in memory with the other variable name will get caught
> on this until they catch on.
Yes. If you think of variables as containers for values in Python you
will be sorry, it is not a model that works.
We had a really good discussion of this not too long ago but I can't
find it in the archives. Does anyone have a link?
Kent
More information about the Tutor
mailing list