variable in Python
Salvatore
artyprog at wanadoo.fr
Thu Apr 17 19:23:58 EDT 2003
Steven Taschuk wrote:
> 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.
>
Thanks Steven
More information about the Python-list
mailing list