title: How to map objects to integers in python?
body: <p>I want to have a map from objects of a class called MyObject to integers. I read some stuff <a href="https://stackoverflow.com/questions/4901815/object-as-a-dictionary-key">here</a>, but didn't understand anything and that doesn't seem to be quite the thing I want. Hash function
  can only be used for collision. What I want to do is to retrieve the value(integer) by
  giving the object as argument. Basically what I look for is a function(in mathematical terms)
  from MyObject to integers.</p>
  
  <p>So suppose this is the definition of my class:</p>
  
  <pre><code>class MyObject:
      def __init__(self,number):
          self.name = name
          self.marked=False
  </code></pre>
  
  <p>So for example</p>
  
  <pre><code>a=MyObject("object 1")
  b=MyObject("object 2")
  </code></pre>
  
  <p>Now I want some mapping like f, that I could assign 25 to a and 36 to b.
  And be able to get:</p>
  
  <pre><code>f(a)=25
  f(b)=36
  </code></pre>