I would like to achieve something similar to this construction:
class Outer:
class A:
foo = 1
class B:
def __init__(self):
self.bar = A.foo
Outer.B().bar # ==> 1
But this fails with
NameError: name 'A' is not defined
I'm not even sure I understand why as A is (I thought) in scope.
Could you help me clarify why this doesn't work and how I could get around it?
A, you would have to useOuter.A, as you'd have to inB.__init__. But why are you using nested classes to begin with? It's not a common pattern in Python... what advantage is it providing?