<br><br><div class="gmail_quote">On 28 November 2010 23:23, 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"><div class="gmail_quote"><div class="im">On Mon, Nov 29, 2010 at 1:21 AM, Michael Foord <span dir="ltr"><<a href="mailto:fuzzyman@voidspace.org.uk" target="_blank">fuzzyman@voidspace.org.uk</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;">
<br><br><div class="gmail_quote"><div>On 28 November 2010 22:37, cool-RR <span dir="ltr"><<a href="mailto:cool-rr@cool-rr.com" target="_blank">cool-rr@cool-rr.com</a>></span> wrote:<br></div><div><div></div>
<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"><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></div><div><br>Unfortunately it would be a backwards incompatible change. Currently catching the TypeError from issubclass is a way of detecting that an object *isn't* a type.<br>

</div></div></blockquote><div><br></div></div><div>Who is doing that?! What's wrong with something like `isinstance(thing, (type, types.ClassType))`?</div><div><br></div></div></div></blockquote><div><br>It doesn't matter who is doing it (or why). If they are writing valid python code we shouldn't break it for them. That's only my opinion - personally I always write the guard and would *like* to see the change. I don't think that's sufficient to break backwards compatibility in this way though.<br>
<br>Michael<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 class="gmail_quote"><div></div><div><br></div><div>
Ram.</div></div>
</div>
</blockquote></div><br><br clear="all"><br>-- <br><a href="http://www.voidspace.org.uk">http://www.voidspace.org.uk</a><br><br><br>