Python equivalent of Archive::Tar?

Tom Robinson tom at
Mon Aug 13 17:22:18 CEST 2001

On Mon, 13 Aug 2001 15:32:40 +0100, Tom Robinson
<tom at> wrote:

>Is there a python equivalent of this perl module?  I specifically want
>to be able to create a tar file in memory by reading in the files for
>it and then write it out to a web browser.  I've managed to acheive
>this in perl by using Archive::Tar, has anyone written a similar
>library for python?  I had a quick search but "tar" always turns up a
>huge amount of unwanted results. :)

It appears I wasn't looking hard enough, see below.  I've managed to
get in Zope to work, but it doesn't have the generality of
Archive::Tar obviously.  Maybe I'll use the Zope code as a base for a
python version...

From: Martin von Loewis (loewis at
Subject: Re: creating compressed tarfiles 
Newsgroups: comp.lang.python
Date: 2000/08/23 

>thomas at (Tw) writes:
>> How can I create compressed tarfiles, ie. lots of files inside a
>> compressed file, using either the or ( found in Zope
>> ) and gzip and/or zlib? 
>> I need examples.
>Without trying, it appears that Zope's already handles
>compressed files.
>Let names contain a list of all files to add, I'd say the following
>might work:
>archive = tar.tgzarchive("foo")
>for n in names:
>  data = open(n).read()
>  archive.add(n, data)
>It appears as if this would keep the compressed file in memory,
>though; there is apparently no streaming tar library.

tom at
remove 'spamfree.' to respond

More information about the Python-list mailing list