zlib compressionobj use: what am I missing?

Titus Brown t at chabry.caltech.edu
Thu Aug 16 23:08:38 CEST 2001

Hi all, I'm working on a patch to the zlibmodule, but I can't get this
bit of code for testing compression objects to work at all.  Should it?
If not, what am I doing wrong??

Help! ;)

    import zlib
    file = open('to-compress')
    compobj = zlib.compressobj(1)
    compdata = ''
    while 1:
        data = file.read(1000)
        if data:
            compdata += compobj.compress(data)

    compdata += compobj.flush()



ps note that this is being run against Python 2.2 from CVS, but the zlibmodule
hasn't changed for a while, so 2.1 users should have the same version I'm

More information about the Python-list mailing list