class MyClass(object):
next_number = 0
def __init__(self):
self.number = self.next_number
MyClass.next_number += 1
class MyClassA(MyClass):
pass
Above it would appear I am forced hardcode the class name when updating the class variable on line 6 since writing:
self.__class__.next_number += 1
results in a new class variable in any derived class. Is there any alternative to hardcoding the class name?
Also on line 5 should I instead write:
self.number = self.__class__.next_number
to make it obvious next_number is a class variable.