[code.view]

[top] / python / PyMOTW / gzip / gzip_write.py

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2008 Doug Hellmann All rights reserved.
     #
     """
     """
     
     __version__ = "$Id$"
     #end_pymotw_header
     
     import gzip
     import os
     
     outfilename = 'example.txt.gz'
     output = gzip.open(outfilename, 'wb')
     try:
         output.write('Contents of the example file go here.\n')
     finally:
         output.close()
     
     print outfilename, 'contains', os.stat(outfilename).st_size, 'bytes of compressed data'
     os.system('file -b --mime %s' % outfilename)
     

[top] / python / PyMOTW / gzip / gzip_write.py

contact | logmethods.com