Phillip J. Eby wrote: >> It seems that the __class__ is only accessed in some cases, but not >> always, leading to what I think is a semantic inconsistency. > > It's not inconsistent - isinstance() checks __class__ in *addition* to > type() in order to allow proxying tricks like lying about your > __class__. It therefore returns true if either your real type *or* your > __class__ matches, and as you can see, the real type is checked first.
This is not the original rationale, though: the check for a __class__ attribute on non-instance objects was introduced in r13520, to support ExtensionClasses. I never fully understood ExtensionClasses, but I believe they were not based on proxying tricks. Instead, they were an early version of new-style classes. Regards, Martin _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com