Variables

Kent Johnson kent37 at tds.net
Sun Apr 24 08:43:56 EDT 2005


Robert Kern wrote:
> Richard Blackwood wrote:
> 
>> Bengt Richter wrote:
>>> Maybe he doesn't know that foo = 5 in Python is not an equation as in 
>>> math,
>>> but a Python source language statement to be translated to a step in 
>>> some
>>> processing sequence.
>>>
>>> Tell him in Python foo is a member of one set and 5 is a member of 
>>> another,
>>> and foo = 5 expresses the step of putting them into correspondence
>>> to define a mapping, not declaring them equal.
>>>  
>>>
>> Could I honestly argue this to him? From what basis do I argue that it 
>> is not an equation?

 From the basis of reality?

 From the point of view of Python, it is an assignment statement, not an 'equation'. According to 
the docs, "Assignment statements are used to (re)bind names to values....[it] evaluates the 
expression list...and assigns the single resulting object to each of the target lists, from left to 
right."
http://docs.python.org/ref/assignment.html

'foo = 5' means the same as d['foo'] = 5 for some dictionary d. Doesn't sound like an equation to me.

It also might be of interest that googling "equation site:docs.python.org" yields a single hit which 
is talking about random distributions.

If your friend (!) is open-minded enough to learn what the semantics of assignment actually are in 
Python then you might be able to have a more productive conversation.

Kent



More information about the Python-list mailing list