Pointers

Grant Edwards nobody at nowhere.nohow
Fri Mar 17 19:26:39 EST 2000


On Wed, 15 Mar 2000 14:25:18 -0800, Curtis Jensen <cjensen at be-research.ucsd.edu> wrote:

>I haven't found anything about pointers in python.  Is there a pointer
>type?  

Yes.

>If so, what is the syntax?

x = 3      

# x is now a pointer to an integer object whose value is 3.

y = "asdf"

# y is now a pointer to a string object whose value is "asdf".

x = y

# x now points to the same object as does y.

z = (0,4,5)

# z points to a tuple containing integer objects 0 4 and 5

a = [x,y,z]

# a is a pointer to a list containing the objects pointed to by x
# y and z

b = a[1]

# b is a pointer to the same object pointed to by y.

# and so on....



All variables are pointers to objects.

The tricky thing is that some objects can be changed, and some
can not.

-- 
Grant Edwards                   grante             Yow!  I was in a HOT
                                  at               TUB! I was NORMAL! I was
                               visi.com            ITALIAN!! I enjoyed th'
                                                   EARTHQUAKE!



More information about the Python-list mailing list