There is a hierchy of classes. Each class may define a class variable (to be specific, it’s a dictionary), all of which have the same variable name. I’d like the very root class to be able to somehow access all of these variables (i.e. all the dictionaries joined together), given an instance of a child class. I can’t seem to find the way to do so. No matter what I try, I always get stuck on the fact that I cannot retrieve the direct parent class given the child class. How can this be accomplished?
Share
As long as you’re using new-style classes (i.e.,
objector some other built-in type is the “deepest ancestor”),__mro__is what you’re looking for. For example, given:now,