diff -r 2a953cb5642d Doc/library/gzip.rst --- a/Doc/library/gzip.rst Tue Apr 08 12:04:04 2014 -0400 +++ b/Doc/library/gzip.rst Tue Apr 08 18:48:36 2014 +0200 @@ -175,9 +175,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::