<br><br><div class="gmail_quote">On Thu, Feb 23, 2012 at 10:43, Antoine Pitrou <span dir="ltr">&lt;<a href="mailto:solipsis@pitrou.net">solipsis@pitrou.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">On Thu, 23 Feb 2012 16:18:19 +0100<br>
brett.cannon &lt;<a href="mailto:python-checkins@python.org">python-checkins@python.org</a>&gt; wrote:<br>
&gt; def _sanity_check(name, package, level):<br>
&gt; &quot;&quot;&quot;Verify arguments are &quot;sane&quot;.&quot;&quot;&quot;<br>
&gt; + if not hasattr(name, &#39;rpartition&#39;):<br>
&gt; + raise TypeError(&quot;module name must be str, not {}&quot;.format(type(name)))<br>
<br>
</div>Why don&#39;t you simply use isinstance()?<br>
(bytes objects also have rpartition())<br></blockquote><div><br></div><div>I think I was on a interface-conformance kick at the time and didn&#39;t want to restrict to a specific type over a specific interface. But since subclasses is not exactly complicated I can change this (which will also match potential C code more with a PyUnicode_Check()). </div>

</div>

AltStyle によって変換されたページ (->オリジナル) /