tarfile.py question

Lars Gustäbel lars at gustaebel.de
Wed Jul 31 10:11:02 EDT 2002


Adonis <deltapigz at telocity.com> wrote:

> x = tarfile.TarFile(sys.argv[1], 'r')

This will work:

x = tarfile.gzopen(sys.argv[1], 'r')

The TarFile class works only for uncompressed tar archive files. 
Whenever you want to open or create a gzipped tar, you have to use 
tarfile.gzopen(). I should have mentioned this a little more clearly in 
the docs.
 
> i attempted to read a tar.gz file (gadfly) and when i load it no error is
> posted nor any information at that, but the  m variable is an empty list,
> and if i attempted to do x.list() to get a list of files it returns None,
> although it seems that it loaded the tar file properly no IOError was
> generated, is there something i am missing? i have tested this by generating
> a tar.gz file using the same module and it unpacked properly.

With the next release, there will be a debug message for this case.
BTW, x.list() prints out the contents of an archive as a directory 
listing, so it'll always return None.

Hope this was helpful.

-- 
Lars Gustäbel
lars at gustaebel.de



More information about the Python-list mailing list