pointers & references in python?

Michael Chermside mcherm at destiny.com
Fri Aug 16 10:06:31 EDT 2002


sami sieranoja wrote:
> is there something like this in python:
> 
> a = 1
> b = &a
> b = 3
> print a
> 
> OUTPUT:
> 3
> 
> 
> 
> -Sami

Yes.

C:\>python
Python 2.2.1 (#34, Apr  9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> a = [1]
 >>> b = a
 >>> b[0] = 3
 >>> print a[0]
3

But I really doubt that's helpful to you. Perhaps if you described what 
you're TRYING to achieve? For instance, the code you showed above would 
NOT work in C or C++.

-- Michael Chermside







More information about the Python-list mailing list