variable in Python

Steven Taschuk staschuk at telusplanet.net
Thu Apr 17 18:09:35 EDT 2003


Quoth Dan Bishop:
  [...]
> The latter: All variables in Python are pointers in disguise.
  [...example...]
> Note that I used a list instead of an int.  With ints, the distinction
> between value and reference semantics doesn't matter as much because
> ints are immutable.

And this is an extremely important point: C programmers who are
familiar with pointer semantics would expect that after
    a = 3
    b = a
    a = 4
we would find b == 4.  This is why, as Aahz pointed out, thinking
of Python variables as pointers can lead one astray, and why you
often see Python variables described as simply "names for
objects", and = as not a value-copying operation (as it is in C)
but a name-binding operation.

-- 
Steven Taschuk                            staschuk at telusplanet.net
Every public frenzy produces legislation purporting to address it.
                                                  (Kinsley's Law)





More information about the Python-list mailing list