isinstance() bug
Michal Vitecek
fuf at mageo.cz
Wed Jan 28 10:41:19 EST 2004
Skip Montanaro wrote:
>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.
i think that if absolute path was somehow put into the classes internal
information this inconsistency would be put away.
it's my belief that if i'm instantiating a class from the same location
no matter how i imported its definition, its instances are always of
the same class.
and as to the sys.modules thing: this could be considered as just two
references to the same module (again its absolute path would be taken
into account), not two different modules.
does it make sense?
--
fuf (fuf at mageo.cz)
More information about the Python-list
mailing list