Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #93393 > unrolled thread

Re: Python 3 resuma a file download

Started byCameron Simpson <cs@zip.com.au>
First post2015-07-02 08:50 +1000
Last post2015-07-02 08:50 +1000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Python 3 resuma a file download Cameron Simpson <cs@zip.com.au> - 2015-07-02 08:50 +1000

#93393 — Re: Python 3 resuma a file download

FromCameron Simpson <cs@zip.com.au>
Date2015-07-02 08:50 +1000
SubjectRe: Python 3 resuma a file download
Message-ID<mailman.228.1435792055.3674.python-list@python.org>
On 01Jul2015 21:51, Peter Otten <__peter__@web.de> wrote:
>zljubisic@gmail.com wrote:
>
>> But how to read chunks?
>
>Instead of
>
>>         data = response.read() # a `bytes` object
>>         out_file.write(data)
>
>use a loop:
>
>CHUNKSIZE = 16*1024 # for example
>while True:
>   data =  response.read(CHUNKSIZE)
>   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.

Cheers,
Cameron Simpson <cs@zip.com.au>

Life is uncertain.  Eat dessert first.  - Jim Blandy

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web