Python variables? [was Re: class implementation]

Rhodri James rhodri at wildebst.demon.co.uk
Mon Sep 30 20:29:16 EDT 2013


On Tue, 01 Oct 2013 00:45:06 +0100, Ned Batchelder <ned at nedbatchelder.com>  
wrote:

>
> On 9/30/13 6:02 PM, Ethan Furman wrote:
>> From your blog:
>>>
>>> Names are Python's variables: they refer to values, and
>>>  those values can change (vary) over the course of your
>>>  program.
>>
>> This is partially incorrect.  If the value referred to by the name is  
>> immutable, then it cannot change; perhaps you meant to say that which  
>> object the name points to can vary over time?
>
> Yes, I meant that 1) names refer to values, and 2) a name can refer to  
> different values over the course of a program.  Hence, the value varies,  
> hence, a variable.

Yes, except no.  The problem is that word "value", which I can practically  
see morphing its meaning through that paragraph.  Names refer to objects,  
which have values or interpretations or however you choose to say it.   
Some (mutable) objects can change their value, some (immutable) can't.   
Independently, names can refer to different objects, which may or may not  
have different values (or indeed concepts of value).

When you say "The value varies", it begs the question "Which 'the value'?"

> In fact, it's more accurate to say that Python has no constants! :)

Or, alternatively, that Python has many constants, such as all those  
immutable integers cached around the place :-)  What it doesn't have is  
fixed bindings.

-- 
Rhodri James *-* Wildebeest Herder to the Masses



More information about the Python-list mailing list