Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #93385
| Path | csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.015 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'subject:Python': 0.05; 'subject:file': 0.07; 'chunks': 0.09; 'cc:addr:python-list': 0.10; 'thu,': 0.15; 'disk.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'in-memory': 0.16; 'subject:download': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.21; 'cc:addr:python.org': 0.21; 'am,': 0.23; '2015': 0.23; 'header:In- Reply-To:1': 0.24; 'second': 0.24; 'message-id:@mail.gmail.com': 0.28; 'attempting': 0.29; 'once,': 0.29; 'skip:u 20': 0.30; 'certainly': 0.31; 'file': 0.34; 'received:google.com': 0.34; 'attempt': 0.35; 'skip:o 20': 0.35; 'subject:: ': 0.37; 'enough': 0.39; 'data': 0.40; 'entire': 0.61; 'jul': 0.72; 'chrisa': 0.84; 'writing.': 0.84; 'to:none': 0.90; 'response,': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=Wk5SgGmutUOrShdYy3elH9ZsS7uWd4pZM3NsKg4+AAY=; b=gn/S/j2EsRG1W3Bm651nx8JFPAuvD34+unCEP59RDNdx0Vcao+2sJVmdrP62lGqXzT qodndUvHU/QEGGexrw/ZHmHin8iHHiHJyJIHiZuSTpJgJghy57s5wnfpFRSgwFlWyRDA SLFzu5uen021ZlO2wSmzqOQcoPWO3Q77Q6ACsix+Vj2UAerZCNGEGTHgoEOVdMqd98jw wUBke6bsFG7KtuNR9VM+6ZoPuOCHp+Dqrlvv7o+XO8p3y/SXnrKSFfYRlPF8qE3sqrD/ jStdEB91swptwjXue5JegCb0YFFvAiTe6L5lWNPEbnUE6gqZspEm/vrG8JzKiQlBIddM GYvQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.176.194 with SMTP id ck2mr7984209igc.2.1435778916823; Wed, 01 Jul 2015 12:28:36 -0700 (PDT) |
| In-Reply-To | <4a7fae78-276e-42c6-9d84-1fddbeb99853@googlegroups.com> |
| 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> |
| Date | Thu, 2 Jul 2015 05:28:36 +1000 |
| Subject | Re: Python 3 resuma a file download |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| 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.225.1435778925.3674.python-list@python.org> (permalink) |
| Lines | 14 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1435778925 news.xs4all.nl 2880 [2001:888:2000:d::a6]:33100 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:93385 |
Show key headers only | View raw
On Thu, Jul 2, 2015 at 5:24 AM, <zljubisic@gmail.com> wrote: > with urllib.request.urlopen(req) as response, open(lfile, 'ab') as out_file: > data = response.read() # a `bytes` object > out_file.write(data) > If a file is big enough to want to resume the download once, you almost certainly want to be able to resume it a second time. I would recommend not attempting to do the entire read and write as a single operation - read chunks and write them to the disk. This will attempt to read the entire response into a gigantic in-memory bytestring, and only then start writing. ChrisA
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