I want to have a map from objects of a class called MyObject to integers. I read some stuff here, 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.
So suppose this is the definition of my class:
class MyObject:
def __init__(self,number):
self.name = name
self.marked=False
So for example
a=MyObject("object 1")
b=MyObject("object 2")
Now I want some mapping like f, that I could assign 25 to a and 36 to b. And be able to get:
f(a)=25
f(b)=36