class A:
x = A.initX()
def __init__(self):
self.y = A.initY()
@staticmethod
def initX():
return 'X'
@staticmethod
def initY():
return 'Y'
In the example above, I am not able to initialize the class A
attribute X
.
The PyCharm editor is complaining of Unresolved reference 'A'
. However, there does not seem to be a problem with initializing the instance attribute of Y
using a similar way.
How do I initialize a class attribute using a static method from the same class?