Pointers
David Robinow
drobinow at dayton.adroit.com
Fri Mar 24 09:10:20 EST 2000
Curtis Jensen <cjensen at be-research.ucsd.edu> wrote in message
news:38DA9F8C.E9133C71 at be-research.ucsd.edu...
> Python does work on a reference setup, but it's not exactly like
> pointers. For example:
> >>> a = 5
> >>> b = a
> >>> a = 3
> >>> print b
> 5
>
> If b were a pointer to b then print b would return 3, not 5. There is
> the problem of mutable types and immutable types here, but the same
> thing occurs if you use a mutable type. So, pointers and python
> referances are not the same.
It's not clear how you get the above conclusion, but it is erroneous.
Consider the following C program.
#include <stdio.h>
int main(int argc, char **argv)
{
int Five = 5;
int Three =3;
int *a, *b;
a = &Five;
b = a;
a = &Three;
printf("a=%d b=%d\n", *a, *b);
}
More information about the Python-list
mailing list