Suppose I have a base class as following:
class User:
user_types = []
def __init__(self, name, age):
self.name = name
self.age = age
And then I want to create a subclass, which will then be added to user_types
class Farmer(User):
def harvest(self):
print("%s just harvested his plantation!" %self.name)
Now I can achieve what I'm trying to do, by simply saying
User.user_types.append(Farmer)
But how could I achieve this if I wanted it to be automatic, and to be done for every subclass? Let's say there will be 400 subclasses, it would be a pain in the ass to manually do that for all of them.