title: Creating a namedtuple with a custom hash function
body: <p>Say I have a <code>namedtuple</code> like this:</p>
  
  <pre><code>FooTuple = namedtuple("FooTuple", "item1, item2")
  </code></pre>
  
  <p>And I want the following function to be used for hashing:</p>
  
  <pre><code>foo_hash(self):
      return hash(self.item1) * (self.item2)
  </code></pre>
  
  <p>I want this because I want the order of <code>item1</code> and <code>item2</code> to be irrelevant (I will do the same for the comparison-operator). I thought of two ways to do this. The first would be:</p>
  
  <pre><code>FooTuple.__hash__ = foo_hash
  </code></pre>
  
  <p>This works, but it feels hacked. So I tried subclassing <code>FooTuple</code>:</p>
  
  <pre><code>class EnhancedFooTuple(FooTuple):
      def __init__(self, item1, item2):
          FooTuple.__init__(self, item1, item2)
  
      # custom hash function here
  </code></pre>
  
  <p>But then I get this:</p>
  
  <pre><code>DeprecationWarning: object.__init__() takes no parameters
  </code></pre>
  
  <p>So, what can I do? Or is this a bad idea altogether and I should just write my own class from scratch?</p>