summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Kuchling <amk@amk.ca>2015-04-14 15:44:40 (GMT)
committerAndrew Kuchling <amk@amk.ca>2015-04-14 15:44:40 (GMT)
commitf887a6180ac374ab91d614584e26c0e30406f571 (patch)
treec5faaf16bb9920da49a24109edf47f63856f5a2a
parent19ddaf6d40efd69d7c5292a24a5bd78b5166465a (diff)
downloadcpython-f887a6180ac374ab91d614584e26c0e30406f571.zip
cpython-f887a6180ac374ab91d614584e26c0e30406f571.tar.gz
cpython-f887a6180ac374ab91d614584e26c0e30406f571.tar.bz2
#21146: give a more efficient recipe in gzip docs
-rw-r--r--Doc/library/gzip.rst3
1 files changed, 2 insertions, 1 deletions
diff --git a/Doc/library/gzip.rst b/Doc/library/gzip.rst
index a8e7704..04c41d5 100644
--- a/Doc/library/gzip.rst
+++ b/Doc/library/gzip.rst
@@ -189,9 +189,10 @@ Example of how to create a compressed GZIP file::
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::