<html><body bgcolor="#FFFFFF"><div><span class="Apple-style-span" style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.296875); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); ">On 18 mars 2011, at 18:04, Raymond Hettinger <<a href="mailto:raymond.hettinger@gmail.com">raymond.hettinger@gmail.com</a>> wrote:</span></div><blockquote type="cite"><div><div><div>On Mar 18, 2011, at 6:58 AM, Mike Graham wrote:</div><blockquote type="cite"><div><font class="Apple-style-span" color="#000000"><br></font>(a) is a misfeature. isinstance checks are bad: they make your code<br>less flexible – in Python the actual type of an object isn't something<br>we treat as semantic data. This is *especially* the case with mixins,<br>which are just a convenient thing for code reuse, not some meaningful<br>type.<br></div></blockquote></div><br><div>I believe that is outdated advice.  Since Guido introduced </div><div>abstract base classes, the trend (and grain) of Python is to</div><div>use isinstance() to check for a given interface (i.e. distinguishing</div><div>a Sequence from a Mapping)</div></div></blockquote>I'm not sure "interface" is the best word here as it probably has java-inherited links to explicit, static specification, whereas a (good) abc instance check would, I believe, check the shape of the testee instead. </body></html>