title: Python - Using the default __hash__ method in __hash__ method definition
body: <p>I have a class, and I wish to write a <code>__hash__()</code> method for this class. The method I want to write will return the default hash of the object in some cases, and a hash of one of its attributes in some others. So, as a simple test case:</p>
  
  <pre><code>class Foo:
      def __init__(self, bar):
          self.bar = bar
      def __hash__(self):
          if self.bar &lt; 10:
              return hash(self) # &lt;- this line doesn't work
          else:
              return hash(self.bar)
  </code></pre>
  
  <p>The problem with this is that <code>hash(self)</code> simply calls <code>self.__hash__()</code>, leading to infinite recursion.</p>
  
  <p>I gather that the hash of an object is based on the <code>id()</code> of that object, so I could rewrite <code>return hash(self)</code> as <code>return id(self)</code>, or <code>return id(self) / 16</code>, but it seems bad form to me to recreate the default implementation in my own code.</p>
  
  <p>It also occurred to me that I could rewrite it as <code>return object.__hash__(self)</code>. This works, but seems even worse, as special methods are not intended to be called directly.</p>
  
  <p>So, what I'm asking is; is there a way to use the default hash of an object without implicitly calling the <code>__hash__()</code> method of the class that object is an instance of?</p>