title: python cast object to int
body: <p>I am using the numpy module to retrieve the position of the maximum value in a 2d array. But this 2d array consists of MyObjects. Now I get the error: </p>
  
  <blockquote>
    <p>TypeError: unorderable types: int() > MyObject()</p>
  </blockquote>
  
  <p>I tried to override the int function with this code:</p>
  
  <pre><code>def int(self):
      return self.score
  </code></pre>
  
  <p>But this does not solve my problem.
  Do I have to convert my 2d array of MyObjects into a 2d array of integers, do I have to extend the Integer object (if this is possible in python) or can I override this int() function in another way?</p>
  
  <p>[EDIT]</p>
  
  <p>The full object:</p>
  
  <pre><code>class MyObject:
  def __init__(self, x, y, score, direction, match):
      self.x = x
      self.y = y
      self.score = score
      self.direction = direction
      self.match = match
  
  def __str__(self):
      return str(self.score)
  
  def int(self):
      return self.score
  </code></pre>
  
  <p>The way I call this object:</p>
  
  <pre><code> def traceBack(self):
      self.matrix = np.array(self.matrix)
      maxIndex = self.matrix.argmax()
      print(self.matrix.unravel_index(maxIndex))
  </code></pre>