I have this class with an unbound method and a static class inside:
class ClassA():
class Foo():
pass
def getFoo():
return ???.Foo
Now, if I inherit a ClassB from ClassA how do I get ClassB.getFoo() to return ClassB.Foo without explicitly implementing ClassB.getFoo()? Returning super().Foo doesn’t work, writing ClassA.Foo doesn’t work either obviously.
Your
getFooshould be a classmethod:Class methods are passed their class as their first argument, similar to how instance methods are passed the instance as the first argument. When you subclass ClassA, the proper class is passed.