New submission from Raymond Hettinger <[email protected]>:
The API for the gzip module is convenient for reading gzipped file but is
rather awkward for reading bytes downloaded from a socket:
>>> import gzip, io
>>> from urllib.request import urlopen, Request
>>> u = urlopen(Request('http://www.nytimes.com', headers={'Accept-Encoding':
'gzip'}))
>>> content = gzip.GzipFile(fileobj=io.BytesIO(u.read()), mode='rb').read()
It would be better if the last line could be written:
>>> content = gzip.decompress_file(u)
----------
components: Library (Lib)
messages: 163004
nosy: rhettinger
priority: normal
severity: normal
status: open
title: Add gzip function to read gzip'd strings
type: enhancement
versions: Python 3.3
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue15087>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com