PyDocs

Nav

Data Compression and Archiving

BZ2Compressor.flush

  • BZ2Compressor.flush()
Finish the compression process.

Returns the compressed data left in internal buffers.

The compressor object may not be used after this method is called.
1 Example
>>> import bz2
>>> def gen_data(chunks=10, chunksize=1000):
...     """Yield incremental blocks of chunksize bytes."""
...     for _ in range(chunks):
...         yield b"z" * chunksize
...
>>> comp = bz2.BZ2Compressor()
>>> out = b""
>>> for chunk in gen_data():
...     # Provide data to the compressor object
...     out = out + comp.compress(chunk)
...
>>> # Finish the compression process.  Call this once you have
>>> # finished providing data to the compressor.
>>> out = out + comp.flush()
from the Python docs
See Also
No see-alsos for bz2/BZ2Compressor.flush
0 Notes
No notes for BZ2Compressor.flush