diff options
author | Andrew Kuchling <amk@amk.ca> | 2015-04-14 11:44:40 -0400 |
---|---|---|
committer | Andrew Kuchling <amk@amk.ca> | 2015-04-14 11:44:40 -0400 |
commit | b015731b5866f19b531042c87f1ca143f856d4d0 (patch) | |
tree | e842ea18b8eb5c3d4e8ff15e85e0cd15f688f0cc | |
parent | 3b3863c2d496f01845eda76ccf6401458714397e (diff) | |
download | cpython-b015731b5866f19b531042c87f1ca143f856d4d0.tar.gz |
#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 a8e77049d3..04c41d585c 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:: |