Skip to content
Advertisement

isinstance() and issubclass() return conflicting results

How do you explain isinstance(Hello,object) returns True whilst issubclass(Hello,object) returns False?

JavaScript

and

JavaScript

Advertisement

Answer

It’s because you are using old-style classes so it doesn’t derive from object. Try this instead:

JavaScript

Old-style classes are deprecated and you shouldn’t use them any more.

In Python 3.x all classes are new-style and writing (object) is no longer required.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement