title: Python's UnboundLocalError and inline variables' assignment
body: <p>Here's a method which returns a method which each time called returns the next fibonacci number (0, 1, 1, 2, 3, 5, ...).</p>
  
  <pre><code>def make_fib():
      j, k = 0, 1
      def fib():
          nonlocal j, k
          result = j
          j, k = k, j+k
          return result
  return fib
  </code></pre>
  
  <p>While the above works fine, if I break the inline assignment of j and k to different assignments, it throws a UnboundLocalError: local variable 'j' referenced before assignment:</p>
  
  <pre><code>  def make_fib():
        j, k = 0, 1
        def fib():
            nonlocal j, k
            result = j
            j = k
            k = j+k
            return result
        return fib
  </code></pre>
  
  <p>Why is that?</p>