Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #93387
| Path | csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!takemy.news.telefonica.de!telefonica.de!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'data:': 0.07; 'subject:file': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:download': 0.16; 'true:': 0.16; 'wrote:': 0.16; 'example': 0.25; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'url:dev': 0.27; 'url:python': 0.33; 'to:addr:python-list': 0.35; 'skip:o 20': 0.35; 'but': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'subject:: ': 0.37; 'instead': 0.38; 'received:org': 0.38; 'url:docs': 0.39; 'to:addr:python.org': 0.39; 'data': 0.40; 'received:de': 0.40; 'email addr:gmail.com': 0.64 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: Python 3 resuma a file download |
| Date | Wed, 01 Jul 2015 21:51:56 +0200 |
| Organization | None |
| References | <9a629cf3-e256-494a-8ff8-3f1f6fc2218c@googlegroups.com> <mailman.204.1435707788.3674.python-list@python.org> <ef677bbd-5b40-40b7-8f56-e6a7d39f9ce0@googlegroups.com> <mailman.219.1435763456.3674.python-list@python.org> <4a7fae78-276e-42c6-9d84-1fddbeb99853@googlegroups.com> <mailman.225.1435778925.3674.python-list@python.org> <36d1cf6d-9b99-4d38-8f07-83443bcd2f60@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p57bd8a45.dip0.t-ipconnect.de |
| User-Agent | KNode/4.13.3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.226.1435780326.3674.python-list@python.org> (permalink) |
| Lines | 25 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1435780326 news.xs4all.nl 2948 [2001:888:2000:d::a6]:39089 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:93387 |
Show key headers only | View raw
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)
This can be simplified:
shutil.copyfileobj(response, out_file)
https://docs.python.org/dev/library/shutil.html#shutil.copyfileobj
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python 3 resuma a file download zljubisic@gmail.com - 2015-06-30 08:34 -0700
Re: Python 3 resuma a file download Cameron Simpson <cs@zip.com.au> - 2015-07-01 09:21 +1000
Re: Python 3 resuma a file download zljubisic@gmail.com - 2015-07-01 07:18 -0700
Re: Python 3 resuma a file download Ian Kelly <ian.g.kelly@gmail.com> - 2015-07-01 09:10 -0600
Re: Python 3 resuma a file download zljubisic@gmail.com - 2015-07-01 12:24 -0700
Re: Python 3 resuma a file download Chris Angelico <rosuav@gmail.com> - 2015-07-02 05:28 +1000
Re: Python 3 resuma a file download zljubisic@gmail.com - 2015-07-01 12:31 -0700
Re: Python 3 resuma a file download Peter Otten <__peter__@web.de> - 2015-07-01 21:51 +0200
Re: Python 3 resuma a file download zljubisic@gmail.com - 2015-07-01 12:59 -0700
Re: Python 3 resuma a file download Peter Otten <__peter__@web.de> - 2015-07-01 22:06 +0200
Re: Python 3 resuma a file download Tim Chase <python.list@tim.thechases.com> - 2015-07-01 15:04 -0500
Re: Python 3 resuma a file download zljubisic@gmail.com - 2015-07-02 13:27 -0700
Re: Python 3 resuma a file download Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2015-07-02 23:31 +0200
Re: Python 3 resuma a file download MRAB <python@mrabarnett.plus.com> - 2015-07-02 23:07 +0100
Re: Python 3 resuma a file download zljubisic@gmail.com - 2015-07-04 22:31 -0700
csiph-web