title: unzipping a file with Python and returning all the directories it creates
body: <p>How can I unzip a <code>.zip</code> file with Python into some directory <code>output_dir</code> and fetch a list of all the directories made by the unzipping as a result? For example, if I have:</p>
  
  <p><code>unzip('myzip.zip', 'outdir')</code></p>
  
  <p><code>outdir</code> is a directory that might have other files/directories in it. When I unzip <code>myzip.zip</code> into it, I'd like <code>unzip</code> to return all the directories made in <code>outdir/</code> as a result of the zipping. Here is my code so far:</p>
  
  <pre><code>import zipfile
  def unzip(zip_file, outdir):
      """
      Unzip a given 'zip_file' into the output directory 'outdir'.
      """
      zf = zipfile.ZipFile(zip_file, "r")
      zf.extractall(outdir)
  </code></pre>
  
  <p>How can I make <code>unzip</code> return the dirs it creates in <code>outdir</code>? thanks.</p>
  
  <p>Edit: the solution that makes most sense to me is to get ONLY the top-level directories in the zip file and then recursively walk through them which will guarantee that I get all the files made by the zip. Is this possible? The system specific behavior of namelist makes it virtually impossible to rely on</p>