On Feb 13, 7:53 pm, Steven D'Aprano <st...@remove-this- cybersource.com.au> wrote: > On Sat, 13 Feb 2010 18:54:34 -0800, Steve Howell wrote: > > On Feb 13, 6:41 pm, a...@pythoncraft.com (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); > var > x: integer; > ptr: ^integer; > > begin > x := 1; > ptr := @x; > ptr^ := ptr^ + 1; > writeln(x); > end. > > For a suitably wide definition of "pointer", then Python does have > pointers: > > 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. >
For a suitably wide definition of pointers CPython does indeed have pointers, and your example is only a weaker case of that truth. There is no reductio adsurbum. If I argued that CPython had curly braced syntax that would be absurd, since it is so concretely wrong. Pointers are a more abstact concept. -- http://mail.python.org/mailman/listinfo/python-list