title: overwrite variable from parent's function scope
body: <p>I'm trying to write a recursive function. When i write code like this one. It works fine.</p>
  <pre><code>def older_func():
      variable = 1
      def func():
         print(variable)
  
         return func
  
      return func
  older_func()(5)
  </code></pre>
  <p>But if I try to reassign my variable after printing i get an error</p>
  <pre><code>def older_func():
      variable = 1
      def func(n):
         print(variable)
         variable = n
         return func
  
      return func
  older_func()(5)
  </code></pre>
  <p>local variable referenced before assignment. on printing step. Please help me understand behavior and way to overcome this.</p>
  <p>UnboundLocalError: local variable 'variable' referenced before assignment</p>