steve+comp.lang.python at pearwood.info
Sat Feb 25 02:38:23 CET 2012
On Sat, 25 Feb 2012 00:39:39 +0000, Mark Lawrence wrote:
> On 24/02/2012 22:25, Steven D'Aprano wrote:
>> On Fri, 24 Feb 2012 10:08:43 -0800, David wrote:
>>> Your code updated to show the difference between a variable, a class
>>> variable, and an instance variable.
>> The preferred terms in Python circles are class and instance
>> *attributes*, not variables.
>> An integer variable is a variable holding an integer.
>> A string variable is a variable holding a string.
>> A list variable is a variable holding a list.
>> Therefore a class variable is a variable holding a class, and an
>> instance variable is a variable holding an instance.
>> Yes, in Python, classes and types are first-class objects (pun not
>> intended), and it is quite common to store them in variables:
>> for cls in (int, float, Decimal, Fraction, myint, myfloat):
>> Other languages may choose to use illogical terminology if they choose.
> Surely you mean names, not variables? :)
Well yes, I do, but the idea of classes being first class objects is
radical enough to some people without also introducing them to the idea
that there are no variables at all!
I'm very aware that name binding is not quite the same as variables in
some other languages, but the difference is subtle and doesn't mean that
the term "variable" is owned by Pascal- or C-like languages. It just
means that, like most computer science terms, "variable" has subtle
differences from implementation to implementation.
More information about the Python-list