[Python-Dev] Should issubclass() be more like isinstance()? (original) (raw)

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Apr 5 02:46:53 CEST 2006


Crutcher Dunnavant wrote:

A) issubclass() throws a TypeError if the object being checked is not a class, which seems very strange.

If I ever pass a non-class to issubclass() it's almost certainly a bug in my code, and I'd want to know about it.

On the rare occasions when I don't want this, I'm happy to write

isinstance(c, type) and issubclass(c, d)

B) issubclass() won't work on a list of classs, the way isinstance() does.

That sounds more reasonable. I can't think of any reason why it shouldn't work.

-- Greg



More information about the Python-Dev mailing list