
David Eppstein wrote:
In article <bncf99$366$1@sea.gmane.org>, "Terry Reedy" <tjreedy@udel.edu> wrote:
A, B, and C *are* instance variables. Why do you think they aren't?
What? They are class attributes that live in the class dictionary, not the instance dictionary.
They are instance variables on the class object, which is an instance of type 'class'.
I think the confusion that is brewing here is how Python masks class attributes when you do an assignment on an instance::
class foo(object): ... A = 42 ... [12213 refs] bar = foo() [12218 refs] bar.A 42 [12220 refs] bar.A = 13 [12223 refs] foo.A 42 [12223 refs] bar.A 13
Python's resolution order checks the instance first and then the class (this is ignoring a data descriptor somewhere in this chain; for the details read Raymond's essay on descriptors @ http://users.rcn.com/python/download/Descriptor.htm#invoking-descriptors ). -Brett