Re: Python variables? [was Re: class implementation]
On Tue, 01 Oct 2013 00:45:06 +0100, Ned Batchelder wrote: On 9/30/13 6:02 PM, Ethan Furman wrote: 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. Yes, except no. The problem is that word "value", which I can practically see morphing its meaning through that paragraph. Names refer to objects, which have values or interpretations or however you choose to say it. Some (mutable) objects can change their value, some (immutable) can't. Independently, names can refer to different objects, which may or may not have different values (or indeed concepts of value). When you say "The value varies", it begs the question "Which 'the value'?" In fact, it's more accurate to say that Python has no constants! :) Or, alternatively, that Python has many constants, such as all those immutable integers cached around the place :-) What it doesn't have is fixed bindings. -- Rhodri James *-* Wildebeest Herder to the Masses -- https://mail.python.org/mailman/listinfo/python-list
Re: Python variables? [was Re: class implementation]
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
Python variables? [was Re: class implementation]
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. 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? -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list