[code.view]

[top] / python / PyMOTW / bz2 / bz2_file_compresslevel.py

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2008 Doug Hellmann All rights reserved.
     #
     """
     """
     
     __version__ = "$Id$"
     #end_pymotw_header
     
     import bz2
     import os
     
     data = open('lorem.txt', 'r').read() * 1024
     print 'Input contains %d bytes' % len(data)
     
     for i in xrange(1, 10):
         filename = 'compress-level-%s.bz2' % i
         output = bz2.BZ2File(filename, 'wb', compresslevel=i)
         try:
             output.write(data)
         finally:
             output.close()
         os.system('cksum %s' % filename)
     

[top] / python / PyMOTW / bz2 / bz2_file_compresslevel.py

contact | logmethods.com