subprocess.call and tar -zxvf
Question: I am trying to call this command `tar -zxvf file.tar.gz` from a python script
and I'm having trouble with it. I've read some relevant q/a's but I still
haven't figured out how to do it.

I was thinking to fit my code to the original command:

    
    
    subprocess.check_call(args, *, stdin=None, stdout=None, stderr=None, shell=False)
    

So far I've made several attempts, as shown below

    
    
    stdin = file.tar.gz
    subprocess.check_call(-zxvf, stdin)
    

Any help? Thanks.


Answer: You can untar a file using the `tarfile` module

    
    
    import tarfile
    tar = tarfile.open("sample.tar.gz")
    tar.extractall()
    tar.close()
    

