Problem with assigning variables of type List

Greg Ewing see_reply_address at something.invalid
Thu Aug 22 08:29:34 CEST 2002


Hans Nowak wrote:

> Greg Ewing wrote:
> 
> Well, the word "variable" does have the connotation of "a little box 
> with a value in it, and assignment changes the value in that box"... 
> That is not how it works in Python,


But it *is* how it works, as long as you understand
that the only kind of value that a box can hold is
a reference to an object.

> and if one thinks variables in 
> Python are the same as in, say, Pascal or C, they're in for a surprise.


If they think a box can hold something other than
a reference, then yes, they will be surprised. But
that doesn't mean they shouldn't think about boxes
at all.

> Maybe that is why some people are reluctant to talk about variables and 
> assignment, and rather use names and bindings. After all, those describe 
> more correctly what's going on.


But then you have to explain what you mean by
names and bindings, which are new terms that
you're introducing just to describe Python concepts.
I can't see how it helps to replace terms which
are already well-understood with new ones that
are completely unknown.

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg




More information about the Python-list mailing list