[prev in list] [next in list] [prev in thread] [next in thread]
List: python-list
Subject: Re: Python variables?
From: Ned Batchelder <ned () nedbatchelder ! com>
Date: 2013-09-30 23:47:49
Message-ID: 524A0DA5.70706 () nedbatchelder ! com
[Download RAW message or body]
On 9/30/13 6:37 PM, Ben Finney wrote:
> Ethan Furman <ethan@stoneleaf.us> writes:
>
>> From [Ned Batchelder]'s 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?
> I agree. Names are not Python's variables.
>
> If anything in Python is a "variable" as generally understood, it is not
> a name. It is a *binding*, from a reference (a name, or some other
> reference like a list item) to a value.
>
> It is the binding which can change over the course of the program, so
> that is the variable.
>
True, but no one calls the binding the variable. Here is a program:
x = 4
Every one of us is perfectly comfortable talking about the variable x.
Don't get hung up on implementation pedantry. The name x here refers to
4. Later it could refer to "four". The value associated with the name
x changed. x is a variable.
--Ned.
--
https://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic