diff options
author | Andrew Kuchling <amk@amk.ca> | 2015-04-14 15:44:40 (GMT) |
---|---|---|
committer | Andrew Kuchling <amk@amk.ca> | 2015-04-14 15:44:40 (GMT) |
commit | f887a6180ac374ab91d614584e26c0e30406f571 (patch) | |
tree | c5faaf16bb9920da49a24109edf47f63856f5a2a | |
parent | 19ddaf6d40efd69d7c5292a24a5bd78b5166465a (diff) | |
download | cpython-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.rst | 3 |
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:: |