isinstance() bug

Skip Montanaro skip at pobox.com
Wed Jan 28 10:28:48 EST 2004


    Michal>  how is it possible that it IS important how you imported a
    Michal>  class definition for isinstance() to work? it's insane!

You imported the module twice (look at sys.modules) so you have two
different A classes.  I believe isinstance() uses the __class__ attribute
and the class's __bases__ attribute to work its way up the class chain
looking for a match.  Even though they are defined identically, you have two
different A classes.  An instance of one can't also be an instance of the
other.

Skip





More information about the Python-list mailing list