<br><br><div class="gmail_quote">On 28 November 2010 22:37, cool-RR <span dir="ltr"><<a href="mailto:cool-rr@cool-rr.com">cool-rr@cool-rr.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr"><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;"><div>`issubclass(1, list)` raises an Exception, complaining that `1` is not a class. This is wrong in my opinion. It should just return False.</div>

<div><br></div><div>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.</div></span><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;"><br>

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`.</span><div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;"><br>
</span></div></div></blockquote><div><br>FWIW (which isn't much I guess) it annoys me that I have to protect calls to issubclass with if isinstance(obj, type).<br><br>It isn't a subclass, so a False would be fine... The advantage of type checking is earlier failures when you're doing something wrong. The disadvantage is, well, all the disadvantages of type checking...<br>
<br>All the best,<br><br>Michael Foord<br><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr"><div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;">
</span></div><div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;"><br></span></div><div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;">Ram.</span></div>

</div>
<br>_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><a href="http://www.voidspace.org.uk">http://www.voidspace.org.uk</a><br><br><br>