compression level with tarfile (w:gz) ?

Benjamin Kaplan benjamin.kaplan at case.edu
Mon Aug 10 15:55:06 CEST 2009


On Mon, Aug 10, 2009 at 9:37 AM, Esmail<ebonak at hotmail.com> wrote:
> Benjamin Kaplan wrote:
>>
>> On Mon, Aug 10, 2009 at 8:50 AM, Esmail<ebonak at hotmail.com> wrote:
>>>
>>> I was wondering if it possible to specify a compression level when I
>>> tar/gzip a file in Python using the tarfile module. I would like to
>>> specify the highest (9) compression level for gzip.
>>>
>>> Ideally:
>>>
>>>  t = tarfile.open(tar_file_name+'.tar.gz', mode='w:gz:9')
>
> <..>
>>
>> Looking at the tarfile docs, it seems that there are tarfile.gzopen
>> and tarfile.bz2open functions that have a compresslevel parameter that
>> defaults to 9. You can't append using those functions but you can read
>> and write.
>
> Hi Benjamin,
>
> I can't find tarfile.gzopen  in the tarfile docs, I'm looking here:
>
>    http://docs.python.org/library/tarfile.html
>
> Am I looking at the wrong page?
>

My mistake. It isn't a function of the tarfile module, it's a class
method of tarfile.TarFile. I was looking at the help in the
interactive interpreter. It doesn't seem to be in the official docs,
but you can use pydoc to view the docstrings.

> Thanks,
>
> Esmail
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list