[Python-ideas] `issubclass` shouldn't be raising exceptions for non-type inputs

cool-RR cool-rr at cool-rr.com
Sun Nov 28 23:37:12 CET 2010


`issubclass(1, list)` raises an Exception, complaining that `1` is not a
class. This is wrong in my opinion. It should just return False.

Use case: I have an object which can be either a list, or a string, or a
callable, or a type. And I want to check whether it's a sub-class of some
base class.

So I don't think I should be taking extra precautions before using
`issubclass`: If my object is not a subclass of the given base class, I
should just get `False`.


Ram.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20101129/bc5e4900/attachment.html>


More information about the Python-ideas mailing list