A question on modification of a list via a function invocation

Rustom Mody rustompmody at gmail.com
Wed Sep 6 00:17:30 EDT 2017


On Wednesday, September 6, 2017 at 9:22:15 AM UTC+5:30, Chris Angelico wrote:
> On Wed, Sep 6, 2017 at 1:42 PM, Stefan Ram wrote:
> > Steve D'Aprano 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.

Well ⅓ the point of pointers may be printing them out — which even in a language 
with 1st class pointers like C is rarely done/needed

Another ⅓ is dereferencing, pointer-arithmetic etc... the various manifestations
of 1st-class pointers

And the third ⅓ is to provide explanations to people asking authentic questions
[like the OP of this thread]

Sure you can say with Steven that this can be 'explained' by saying an object
can be in two places at one time.
Others would then say 'Humpty-dumpty!' since you have removed the most basic
intuition of objects and you are in effect saying that a python object
means what you ordain it means without further ado/explanation

Since you believe a reference-less dictionary can be a model for such explanations,
why not provide that?



More information about the Python-list mailing list