Nick the Gr33k writes:
> On 16/6/2013 12:22 μμ, Denis McMahon wrote:
> > For example, in Python
> >
> > a = 6
> > b = a
> > c = 6
> >
> > a and b point to one memory location that contains the value 6
> > c points to a different memory location that contains the value 6
> 
> I believe you are mistaken.
> 
> a here is not a pointer but variable,
> which is a memory location that stores value 6.
> 
> b here is a pointer. It's value is the memory location of variable a
> which stores value 6.
> 
> c here is just te same as a , a variable.

b is also just like a.

All the talk about pointers and memory locations is intended to
explain how things do or do not change. (Or, sometimes, how the
behaviour is implemented.)

If, instead of the above, you have

a = 6
b = a
b = 5

you will find that b == 5 and a == 6. So b is not the same as a. Else
one would have changed when the other changed. I would say that a and
b are different variables. They had the same value, briefly.

What does same mean? Think of mutable objects. A dictionary, for
example:

a = dict(x = 3)
b = a
b.update(x = 31)

You will find that the value of a changed when the value of b changed.
It's the same value. Values do not get copied in Python when you pass
them around. This is implemented with pointers and memory locations,
but in Python these implementation details are normally hidden behind
the scenes.

Python is far from unique in this regard.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to