Below, base_id
and _id
is a class variable and shared among all child classes.
Is there a way to separate them into each class?
If you don't want to violate the DRY principle like falsetru suggests, you'll need to use metaclasses. I was thinking of writing something up, but there's already a good long description of metaclasses on SO, so check it out.
Metaclasses, in short, let you control subclass creation.
Basically, what you need to do is, upon the creation of a subclass of Parent
, add the _id
member to the newly-created subclass.