Modifying Class Object

Steven D'Aprano steve at
Sun Feb 14 04:53:42 CET 2010

On Sat, 13 Feb 2010 18:54:34 -0800, Steve Howell wrote:

> On Feb 13, 6:41 pm, a... at (Aahz) wrote:

> > Regardless of how CPython manages its state internally, Python as a
> > programming language does not have pointers.  
> I agree with your statement for a suitably narrow definition of the
> words "pointer" and "have."

"Suitably narrow" is not that narrow. By no stretch of the imagination 
can one say that Python has a built-in pointer type analogous to pointers 
in (say) Pascal or C -- you can't usefully get the address of a variable 
(although the CPython implementation leaks the address of objects, it 
does so in a way that is safe and useless for everything but a label). 
There is no equivalent to (say) the Pascal program:

program main(input, output);
    x: integer;
    ptr: ^integer;

  x := 1;
  ptr := @x;
  ptr^ := ptr^ + 1;

For a suitably wide definition of "pointer", then Python does have 

data = ['aaa', 'bbb', 'ccc', 'ddd', 'eee']
i = data.index('bbb')
print data[i]
i += 1
data[i] = 'zzz'

but I trust that we all agree that describing the integer offset i above 
as a "pointer" is a reductio ad absurdum.


More information about the Python-list mailing list