Question are at the end of this post.
First snippet: empty local variable dictionary.
def outer(): x = 1 def inner():
there is an explanation Why am I getting an UnboundLocalError when the variable has a value? on the python docs faq page, similar to the above answers by abarnert and Martijn.