<br><br><div class="gmail_quote">On Thu, Sep 1, 2011 at 11:37 AM, Hugo Arts <span dir="ltr">&lt;<a href="mailto:hugo.yoshi@gmail.com">hugo.yoshi@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5">On Thu, Sep 1, 2011 at 5:28 PM, Richard D. Moores &lt;<a href="mailto:rdmoores@gmail.com">rdmoores@gmail.com</a>&gt; wrote:<br>
&gt; Thanks, James, from your ideas I&#39;ve come up with this function as a<br>
&gt; general test for hashibility of any object:<br>
&gt;<br>
&gt; def is_hashable(object):<br>
&gt;    try:<br>
&gt;        if hash(object):<br>
&gt;            return True<br>
&gt;    except TypeError:<br>
&gt;        return False<br>
&gt;<br>
&gt; But is it?  It returns True for ints, floats, sets, tuples, strings,<br>
&gt; functions; and False for lists<br>
&gt;<br>
&gt; Dick<br>
<br>
</div></div>Are you sure? In my testing it returns False for sets, but True for<br>
frozensets as it should.<br>
</blockquote></div><br><div>I agree with hugo, I just tested with all of these:</div><div><br></div><div><div>a = &#39;a&#39;</div><div>b = []</div><div>c = 1</div><div>d = ()</div><div>e = set()</div><div>f = frozenset()</div>
</div><div><br></div><div>it gave the correct response for each</div><div><br></div><div><div>a = &#39;a&#39; - True</div><div>b = [] - False</div><div>c = 1 - True</div><div>d = () - True</div><div>e = set() - False</div>
<div>f = frozenset() - True</div></div>