Guest User

Untitled

a guest
Sep 24th, 2011
224
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mattb@Zed ~
  2. $ ./gz.py
  3. 1000
  4. 1000
  5. 2000
  6.  
  7. mattb@Zed ~
  8. $ cat gz.py
  9. #!/usr/bin/env python
  10.  
  11. import gzip
  12. import struct
  13.  
  14. data = '0123456789' * 100
  15.  
  16. f = gzip.open('foo.gz', 'wb')
  17. f.write(data)
  18. f.close()
  19.  
  20. f = open('foo.gz', 'rb')
  21. f.seek(-4, 2)
  22. print struct.unpack('<I', f.read())[0]
  23. f.close()
  24.  
  25. f = gzip.open('foo.gz', 'ab')
  26. f.write(data)
  27. f.close()
  28.  
  29. f = open('foo.gz', 'rb')
  30. f.seek(-4, 2)
  31. print struct.unpack('<I', f.read())[0]
  32. f.close()
  33.  
  34. f = gzip.open('foo.gz', 'rb')
  35. print len(f.read())
  36. f.close()
RAW Paste Data