Python 3 resuma a file download

Peter Otten __peter__ at
Wed Jul 1 21:51:56 CEST 2015

zljubisic at wrote:

> But how to read chunks?

Instead of

>         data = # a `bytes` object
>         out_file.write(data)
use a loop:

CHUNKSIZE = 16*1024 # for example
while True:
   data =
   if not data:

This can be simplified:

shutil.copyfileobj(response, out_file)

More information about the Python-list mailing list