It\'s ok to get and print the outer function variable a
a
def outer(): a = 1 def inner(): print a
It\'s also ok
In Python 3 you can do this with the nonlocal keyword. Do nonlocal a at the beginning of inner to mark a as nonlocal.
nonlocal
nonlocal a
inner
In Python 2 it is not possible.