Mar-21-2022, 01:25 PM
(This post was last modified: Mar-21-2022, 01:25 PM by deanhystad.)
Class variable, not static variable. This is Python, not C++.
The answer to your question is yes and no. You cannot use class variables in Outer when assigning class variables in Inner because class Outer does not exist yet when you create class variables for Inner. However, methods in Inner can see Outer just fine.
The answer to your question is yes and no. You cannot use class variables in Outer when assigning class variables in Inner because class Outer does not exist yet when you create class variables for Inner. However, methods in Inner can see Outer just fine.
class Outer(object): a = 1 class Inner(object): a = 2 @classmethod def aay(cls): return cls.a, Outer.a print(Outer.Inner.aay())
Output:(2, 1)
This also works for instance methods of Inner.