On Wed, Sep 6, 2017 at 1:42 PM, Stefan Ram <r...@zedat.fu-berlin.de> wrote: > Steve D'Aprano <steve+pyt...@pearwood.info> writes: >>So in what sense are references part of the Python language? > > It would be possible to describe Python using a concept > called "reference", it's just that the The Python Language > Reference, Release 3.6.0 (PRL) does /not/ do this. > And programming language experts usually use the terms that > the language specification uses with the meaning that the > language specification is giving them. And this is why I say > that JavaScript and Python do not have references. > (Except "attribute references".) > >>Inside the interpreter, you (probably?) could print out the value of the >>pointer, or manipulate it in some fashion. > > Well, this /is/ from the PRL: > > »An object's identity never changes once it has been created; > you may think of it as the object's address in memory.«. > ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ > - The Python Language Reference, Release 3.6.0; > 3.1 Objects, values and types > > It's not called "reference", it's called "identity". But it > might agree with your idea of a pointer of an implementation. > And you /can/ print it. > >>>> print( id( 'abc' )) > 4163144
Printing out an address is only half the point (pun intended) of a pointer - and the useless half. Given a pointer, you need to be able to dereference it. How can you, given the id of a Python object, access the object itself? The nearest I've ever seen is a function that searches every object it can find, looking for one with the same id. I *might* be able to accept the argument that pointer arithmetic isn't important (though I'm still of the opinion that without arithmetic, they're just references/name bindings), but if you want to say that the id() of a Python object is its pointer, you MUST demonstrate this more basic feature. ChrisA -- https://mail.python.org/mailman/listinfo/python-list