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
A generally cleaner way to do this would be:
def outer(): a = 1 def inner(b): b += 1 return b a = inner(a)
Python allows a lot, but non-local variables can be generally considered as "dirty" (without going into details here).