title: Python: Recursion: Passing some value down through the calls
body: <p>Look at this snippet:</p>
  
  <pre><code>def recur(n):
      ds = {}
      x=do_foo(n)
      if foo(n): ds[n] = recur(x)
      else: return x
  </code></pre>
  
  <p>what i want to ask is ds at first iteration is empty and then it adds on some condition if true. if it recurs, on second iteration it enters at <code>ds[n] = recur(x)</code> so in this nth iteration ds is again defined as ds = {}.. OR ds retains its previous elements. If it doesn't, then how to retain the elements?</p>