The problem is that you're using a staticmethod
, and hardcoding the class A
, instead of using a classmethod
, and using the cls
argument.
Try this:
class A:
c=1
@classmethod
def b(cls): return cls.c
The docs (linked above) explain the difference, but you may want to try looking at Stack Overflow questions like What is the difference between @staticmethod
and @classmethod
in Python for a more in-depth discussion. Briefly: a staticmethod
is basically just a global function inside the class's namespace, while a classmethod
is a method on the class object; if you want to use any class attributes (or the class itself, as in the alternate constructor idiom), you want the latter.