Finding the instance reference of an object

Aaron Brady castironpi at gmail.com
Sun Nov 2 16:23:11 EST 2008


On Oct 31, 3:23 am, Steven D'Aprano <st... at REMOVE-THIS-
cybersource.com.au> wrote:
> On Thu, 30 Oct 2008 19:55:57 -0700, Aaron Brady wrote:
> > On Oct 30, 9:05 pm, Steven D'Aprano <st... at REMOVE-THIS-
> > cybersource.com.au> wrote:
> >> On Fri, 31 Oct 2008 13:58:13 +1300, greg wrote:
> >> > Dale Roberts wrote:
>
> > snip
>
> >> > If they understand how assignment works in Python, that tells them
> >> > all they need to know.
>
> >> Nonsense.
>
> > Maybe I missed this part.  What does the phrase, "value of variable x"
> > mean in Python?  Is it the same as what it means in C, Pascal, etc.?
>
> > In other words,
>
> >>>> x= [ 2, 3, 4 ]
> >>>> '0x%x'%id( x )
> > '0xb39dd0'
>
> > What is the value of 'x'?
> > a) [ 2, 3, 4 ]
> > b) An object with contents [ 2, 3, 4 ]
> > c) 0xb39dd0
> > d) None of the above.
>
> Solution a) is just shorthand for b), because there are (or at least
> could be) many such objects [2, 3, 4]. So I'd accept either a) or b) as
> reasonable answers.

snip

I'm actually going to take issue with this... not to beat a dead
horse.  (a) and (b) are distinct, at least potentially, and Steven did
not supply the burden of proof necessary for answering more than one.

More specifically, I want a definition of what it means "to copy an
object onto the stack".  If one wanted to say, "copy a reference to it
onto the stack", would one say it, necessarily and always?  In other
words, can one infer from a fact that one didn't say the latter, that
one didn't mean it?

People just express themselves and don't always speak with
mathematical precision.  But, doing so, an object is not the same as a
reference to it, and all Python does is pass and copy references.

In fact, observing that the equals sign is not a mutating operation,
I'd even hold that Python calls by reference.



More information about the Python-list mailing list