Variables

Richard Blackwood richardblackwood at cloudthunder.com
Sun Apr 24 00:02:55 EDT 2005


Robert Kern wrote:

> Richard Blackwood wrote:
>
>> Kent Johnson wrote:
>>
>>> Richard Blackwood wrote:
>>>
>>>>>> To All:
>>>>>>
>>>>>>    Folks, I need your help. I have a friend who claims that if I 
>>>>>> write:
>>>>>>
>>>>>> foo = 5
>>>>>>
>>>>>> then foo is NOT a variable, necessarily. 
>>>>>
>>>>>
>>>>>
>>>>>
>>>> Indeed, this language is math. My friend says that foo is a 
>>>> constant and necessarily not a variable. 
>>>
>>>
>>>
>>>
>>> Well, we mostly talk Python here, not math. In Python, if you say
>>> foo = 5
>>> foo is a name bound to an immutable value.
>>>
>>> If I had written foo = raw_input(), he would
>>>
>>>> say that foo is a variable. 
>>>
>>>
>>>
>>>
>>> That's funny. foo is still a name bound to an immutable (string) 
>>> value. foo is no more or less variable than it was with foo = 5.
>>>
>>> Which is perfectly fine except that he
>>>
>>>> insists that since programming came from math, the concept of 
>>>> variable is necessarily the identical. This can not be true. For 
>>>> example, I may define foo as being a dictionary, but I can not do 
>>>> this within math because there is no concept of dictionaries within 
>>>> mathematics; yet foo is a variable, a name bound to a value which 
>>>> can change.
>>>
>>>
>>>
>>>
>>> Sounds like you are having a stupid and meaningless argument with 
>>> your friend. What you call foo won't change what it is. He should 
>>> learn Python, then he would understand the true zen of foo.
>>
>>
>>
>> That is exactly how I feel about it. Foo is what it is. Variable, 
>> name bound to immutable value, etc., what we call it doesn't really 
>> change how I program, only how I communicate with other programmers 
>> (and mathematicians). Is the notion of variable not a fundamental 
>> concept in programming?  Surely there must be an unambiguous 
>> definition I can relay to him.
>
>
> Why should there be? Different programming languages have different 
> models. In C, a variable corresponds to a memory slot. In Python, it's 
> a just a name that can be bound to an object.
>
> If you must, http://en.wikipedia.org/wiki/Variable
>
Fantastic, wikipedia deals precisely with the difference between 
variables in mathematics versus programming. However, he would never 
trust a definition from such an "unreputable" source. If you have any 
other sources I might direct him to...he maintains that the notion of 
foo being a variable where it's value is known (versus unknown) is 
illogical.



More information about the Python-list mailing list