Nested function scope problem

Antoon Pardon apardon at forel.vub.ac.be
Sat Jul 29 12:47:37 EDT 2006


On 2006-07-28, Gerhard Fiedler <gelists at gmail.com> wrote:
> On 2006-07-28 15:20:52, Antoon Pardon wrote:
>
>>> Typically, "variable" implies a data storage location that can take on
>>> different values. Emphasis on "location" -- the name is fixed to a
>>> memory location whose contents can be varied.
>> 
>> That is not true. It may be the case in a number of languages but my
>> experience with lisp and smalltalk, though rather limited, says that no
>> such memory location is implied with the word "variable" in those
>> languages and AFAIK they don't have a problem with the word "variable"
>> either. 
>> 
>>> In Python, the closest would be a mutable object.
>
> Maybe this gets somewhere. Consider variable != constant. Python names are
> variables in that what they refer to (what is associated with them through
> a dict) can be changed, through various means (most commonly assignment).
> They are also variables in that what they refer to (usually) can be
> changed. Whether an assignment or some other command changes the reference
> association or the referenced object is one of the confusing issues with
> Python. But that doesn't make a variable less variable... :)

I think the important thing to remember is that the assignment in Python
is a alias maker and not a copy maker. In languages like C, Fortran,
pascal, the assignment makes a copy from what is on the righthand and
stores that in the variable on the lefthand. In languages like Lisp,
Smalltalk and Python, the assignment essentially makes the lefthand
an alias for the righthand.

-- 
Antoon Pardon



More information about the Python-list mailing list