title: Python3: lzma unpack .7z file
body: <p>I would like to unpack a .7z file. According to this <a href="https://stackoverflow.com/questions/18868934/is-there-an-equivalent-of-gzip-open-for-7z-files">question</a> I can use the 
  <a href="https://docs.python.org/3.3/library/lzma.html" rel="noreferrer">lzma</a> package to do this.</p>
  
  <p>I was expecting something like</p>
  
  <pre><code>import lzma
  #...
  with lzma.open('myFile.7z') as f:
      f.extractall('.')
  </code></pre>
  
  <p>To extract the file into the current directory but it seems something like this does not exist. Furthermore trying something like</p>
  
  <pre><code>import lzma
  #...
  with lzma.open('myFile.7z') as f:
      file_content = f.read()
      print(file_content)
  </code></pre>
  
  <p>did yield <code>_lzma.LZMAError: Input format not supported by decoder</code>. How can I check the format? And I am quite surprised because I thought both 7zip and the .7z format are open source and python should support everything.</p>
  
  <p>I saw a lot of answers where people were just calling the 7zip executable with a subprocess but this is not want I want to do. I am looking for a plain python3 solution.</p>