Python 3 resuma a file download

Cameron Simpson cs at
Thu Jul 2 00:50:10 CEST 2015

On 01Jul2015 21:51, Peter Otten <__peter__ at> wrote:
>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:
>       break
>   out_file.write(data)

It might be worth noting here that Peter's "chunk" is just an arbitrary amount 
of data to read in a unit. I'm only mentioning this because the HTTP 
specification has a "chunked-encoding" used to return binary files, and we are 
not talking about _those_ chunks.

Cameron Simpson <cs at>

Life is uncertain.  Eat dessert first.  - Jim Blandy

More information about the Python-list mailing list