[Python-Dev] Semantic of isinstance
Phillip J. Eby
pje at telecommunity.com
Tue Jun 27 05:41:17 CEST 2006
At 08:04 PM 6/26/2006 -0700, Martin Maly wrote:
>Thanks for the response. The code snippet I sent deals with new style
>classes only so I assume that in some cases isinstance falls back to
>old-style-like handling which then asks for __bases__ and __class__ etc,
>possibly incorrectly so on new style classes.
Actually, it's correct behavior for isinstance() to inspect __class__, even
on new-style classes. I suspect that the question of checking for
__bases__ in one of the shortcut branches just didn't come up when the code
was being written. This does appear to be a language design question,
regarding how much of this machinery one is allowed to emulate.
More information about the Python-Dev
mailing list