Finding the instance reference of an object

Steven D'Aprano steve at
Fri Oct 31 10:23:27 CET 2008

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-
>> 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.

Solution c) is the answer that is required for "Python is call-by-value" 
to be correct. 

> If "value of 'x'" is not defined, we should agree on a definition that's
> really clear and useful, favoring useful.

The ordinary dictionary meaning is sufficient: "what is denoted by a 

> After that's established, we
> can proceed to evaluating what 'call by value' would behave like, which
> would then determine if Python behaves like it.

Call by value is traditionally defined in at least some languages as 
meaning that a copy of the value of the parameter is passed to the 
function. Those languages include C and Pascal, and possibly Basic. I'd 
estimate that 80% of programmers over the last 40 years have had their 
understanding of "call by whatever" shaped by those three languages.

> So, logically, if... she... weighs... the same as a duck,... she's made
> of wood.

Nice one :)


More information about the Python-list mailing list