Counting instances of a class?
You could consider using a class attribute to provide a counter. Each instance needs only to ask for the next value. They each get something unique. Eg: from itertools import count class Obj(object): _ids = count(0) def __init__(self): self.id = next(self._ids)