title: Os.walk() alternatives
body: <p>I'm writing a program that needs to explore all possible subdirectories of a given path topdown.
  My problem is that I need to do things before calling recursion and after finish recursion and <code>os.walk()</code> doesn't allow this. More precisely the recursion in the directories subtree that I need is:</p>
  
  <p>(Note: is not real Python code, just Python-like code to explain what I need to do)</p>
  
  <pre><code>def recursion(path):
      action1()
     for subdir in path:
         recursion(path+subdir)
     action2()
  </code></pre>
  
  <p>while what I can do with <code>os.walk()</code> is simply:</p>
  
  <pre><code>def recursion(path):
      action1()
      action2()
      for subdir in path:
          recursion(path+subdir)
  </code></pre>
  
  <p>Is there any solution?</p>