In python I am able to access the variable in outer function from the inner function and hence it forms a closure. However, I am not able to access a variable in outer class from the inner class like this,
>>> class A:
... a=1
... class B:
... b=1
... def pr(self):
... print a,b
...
>>> c=A().B()
>>> c.pr()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 6, in pr
NameError: global name 'a' is not defined
Why is this kind of closure not possible in python?