[Python-Dev] Re: closure semantics
Brett C.
bac at OCF.Berkeley.EDU
Fri Oct 24 21:16:41 EDT 2003
More information about the Python-Dev mailing list
Fri Oct 24 21:16:41 EDT 2003
- Previous message: [Python-Dev] Re: closure semantics
- Next message: [Python-Dev] Re: closure semantics
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
David Eppstein wrote: > In article <bncf99$366$1 at sea.gmane.org>, > "Terry Reedy" <tjreedy at 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
- Previous message: [Python-Dev] Re: closure semantics
- Next message: [Python-Dev] Re: closure semantics
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list