title: Python: Renaming member in a tar file during extraction
body: <h2>Premise</h2>
  
  <ul>
  <li>I have a directory <code>/foo/bar</code></li>
  <li>I have a tar file containing the directory <code>baz</code></li>
  </ul>
  
  <h2>Problem</h2>
  
  <p>Extracting the contents of <code>baz</code> in the archive to <code>/foo/bar</code></p>
  
  <h2>Example</h2>
  
  <p>The archive contains:</p>
  
  <pre>
  baz/
   file1.txt
  </pre>
  
  <p>The source directory contains:</p>
  
  <pre>
  foo/
    bar/
      file2.txt
  </pre>
  
  <p>After extraction I want it to be:</p>
  
  <pre>
  foo/
    bar/
      file1.txt
      file2.txt
  </pre>
  
  <h2>Solutions so far</h2>
  
  <p>Extract to a temporary directory and then move the contents of <code>baz</code> to the target location, this works since I the <code>baz</code> directory will always have the same name.</p>
  
  <p>Any other ideas?</p>