This seems an odd request - would it not be more readable to refer to the index by obj.index instead of obj()?
Regardless, if I'm understanding you right, you can get the functionality you want by subclassing the int type:
class keep_index(int):
def __new__(cls, value, index):
obj = int.__new__(cls, value)
obj.index = index
return obj
def __call__(self):
return self.index The int type appears to use __new__ for setup, rather than __init__, which is why I had to override __new__ in order to get it to accept two parameters.