pointer

Andrey Panchenko andrey at app.omsk.su
Tue Apr 9 12:02:51 EDT 2002


"Oleg Broytmann" <phd at phd.pp.ru> wrote:
> On Tue, Apr 09, 2002 at 04:45:08PM +0200, Henning Peters wrote:
> > is there anything similar to the pointer concept from c/c++ in python?
>
>    In Python *everything* is a pointer. Really.
>
> > i would like to store values in two different locations. both values
should
> > always be equal. the one could be a pointer on the other. is this
possible
> > to do this in python?
>
> a = 1 # put a pointer to an Integer objetc into variable a
> b = a # copy the pointer into b; now both b and a hold pointers to the
same
>       # Integer object
>
> c = [a, b] # make a list holding two pointers
>
I think it's rather an ambiguous statement. I can think that after

a = 1
b = a
a = 3

b must hold 3. But it's not true. IMHO it's better to say that the python
names are like pointers only for mutable objects.
(Caution - newbie opinion)

Andrey mailto:andrey at app.omsk.su






More information about the Python-list mailing list