[Python-checkins] cpython: #21146: give a more efficient recipe in gzip docs
andrew.kuchling
python-checkins at python.org
Tue Apr 14 17:45:18 CEST 2015
https://hg.python.org/cpython/rev/ae1528beae67
changeset: 95640:ae1528beae67
user: Andrew Kuchling <amk at amk.ca>
date: Tue Apr 14 11:44:40 2015 -0400
summary:
#21146: give a more efficient recipe in gzip docs
files:
Doc/library/gzip.rst | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/Doc/library/gzip.rst b/Doc/library/gzip.rst
--- a/Doc/library/gzip.rst
+++ b/Doc/library/gzip.rst
@@ -189,9 +189,10 @@
Example of how to GZIP compress an existing file::
import gzip
+ import shutil
with open('/home/joe/file.txt', 'rb') as f_in:
with gzip.open('/home/joe/file.txt.gz', 'wb') as f_out:
- f_out.writelines(f_in)
+ shutil.copyfileobj(f_in, f_out)
Example of how to GZIP compress a binary string::
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list