@Martjin Pieters has the right idea, but I would suggest going with itertools.count for this one:
class MyObject(object):
ID = itertools.count()
def __init__(self):
self.id = MyObject.ID.next()
>>> MyObject().id
0
>>> MyObject().id
1
>>> MyObject().id
2
>>> MyObject.ID
count(3)
Hope this helps