On 9/30/13 6:02 PM, Ethan Furman wrote:
On 09/30/2013 02:28 PM, Ned Batchelder wrote:
On 9/30/13 3:34 PM, Dave Angel wrote:
Python doesn't actually have variables, but the things it documents as
variables are local names within a method.  Those are not visible
outside of the method, regardless of whether you're in a class or a
subclass.

Why does this meme persist!? Of course Python has variables, they just don't work like C variables do. If you'd like
to know the details: http://nedbatchelder.com/text/names.html

Because Python's model is different enough that it usually makes thinking about it simpler to stay away from the word 'variable'; in every other language I have used a variable is a box, but in Python it's a label for a box.


It might help C programmers to stay away from "variable," but some people claim we should avoid the word so as not to confuse beginners. That's just silly. Beginners have no holdover concepts from C. Lots of languages use the same names and values model that Python does: Javascript, Java, Ruby, Lisp, etc.

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.

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

--Ned.

--
~Ethan~

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to