bz2 module

Brad Tilley bradtilley at
Mon Oct 18 22:18:11 CEST 2004

I'm having a bit of trouble using the bz2 module. The documentation for 
it is very poor. Here's what I'm trying to do:

import bz2

x = file('test.bkf', 'rb')

while True:
         data =
         if not data:
         bz2.BZ2File('test.bkf.copy', 'w').write(data)


It fails with this error:
AttributeError: 'module' object has no attribute 'BZ2File'

Can anyone give me an example of how to use bz2 to compress files. Why 
don't the docs give examples of this?!?


More information about the Python-list mailing list