On Apr 17, 2009, at 8:56 PM, Steven D'Aprano wrote:
If an integer variable is an integer, and a string variable is a
string,
and float variable is a float, and a list variable is a list
(there's a
pattern here), shouldn't a class variable be a class and an instance
variable be an instance?
I had never noticed the usage of "variable" to mean attribute until
a few
months ago. What's going on? Why did people decide that confusing
variables and attributes of variables was a good thing? What's next,
describing dictionary keys as "dictionary variables"?
(Replying to this old message because I've seen you make this point in
several threads recently)
Let me prefix this by saying: I don't like to use the word "variable"
when being specific about Python, because its meaning isn't well
established like "name" or "object". Personally, I think most people
use "variable" when they're thinking about Python in terms of C-style
assignment semantics (which isn't accurate, but as a newbie you can
get away with it for a little while), or when they're conflating a
name with the object it refers to. But I don't think there's a well-
established definition in Python (because it implies a storage model
that Python doesn't use), and it certainly isn't synonymous with
"object".
As far as "class variable" and "instance variable" go:
They're used across many object-oriented languages:
http://en.wikipedia.org/wiki/Class_variable
The Python language reference uses that terminology:
http://docs.python.org/reference/datamodel.html
As does Guido himself:
http://people.csail.mit.edu/rudolph/Teaching/Lectures/guido-intro-2.pdf
We're blessed with a variety of object-oriented almost-synonyms to
choose from, some of which are more Pythonic than others. But I don't
think it's worth "correcting" everyone who uses the phrase "class
variable", especially when their use of it causes no confusion.
-Miles
--
http://mail.python.org/mailman/listinfo/python-list