[Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Include rangeobject.h,2.16,2.17

Tim Peters tim.one@home.com
Mon, 9 Jul 2001 01:08:50 -0400

[Barry A. Warsaw]
> ...
> I know there's no danger in changing the behavior for an explicit
> instance.attr access.  We all agree that that should always raise
> AttributeError, right? :)

Please, let's be serious here.  How an instance looks up attributes is
obviously a policy of the instance's class, and class policies are obviously
set by the class of which the instance's class is an instance, or, in other
words, by the instances's class's metaclass.  Unless you want to say that
class policies are inherited from base classes, in which case an entirely
different line of obvious argument obviously applies -- but that would be
wrong.  Now if the metaclass is of type type, then all you have to do is
look at PyType_Type.tp_getattr == type_getattr, and we see that it raises
AttributeError unless the attribute is one of "__name__" or "__doc__" or
"__members__".  So, yes,


will *always* raise AttributeError in this case, because PyType_Type doesn't
allow for the existence of any attribute named "attr".  From that we deduce
that looking up instance attributes is probably not a class policy
determined by the metaclass after all, so some other obvious argument must

I'll get back to you after rereading all the PEPs.  But it would be better
for all if you didn't ask such obvious questions to begin with <wink>.

thinking-too-much-is-a-symptom-of-disease-ly y'rs  - tim