Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82082
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.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.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; '"this': 0.03; '(even': 0.05; 'subject:Python': 0.06; 'debug': 0.07; 'debugging': 0.07; 'explicit': 0.07; 'exception,': 0.09; 'explanation': 0.09; 'handful': 0.09; 'subject:using': 0.09; 'try:': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; 'def': 0.12; 'missed': 0.12; 'buggy': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'generator.': 0.16; 'iterators': 0.16; 'trivially': 0.16; 'version;': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'written': 0.21; 'cc:addr:python.org': 0.22; 'affects': 0.24; "aren't": 0.24; 'why.': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'this:': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'fixed': 0.29; 'am,': 0.29; 'dec': 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; "d'aprano": 0.31; 'obscure': 0.31; 'raised': 0.31; 'steven': 0.31; 'terminate': 0.31; 'run': 0.32; 'quite': 0.32; 'cases': 0.33; 'guess': 0.33; "i'd": 0.34; 'could': 0.34; 'except': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'version': 0.36; 'yield': 0.36; 'too': 0.37; 'clear': 0.37; 'easily': 0.37; 'being': 0.38; 'rather': 0.38; 'short': 0.38; 'how': 0.40; 'future': 0.60; 'most': 0.60; 'new': 0.61; 'simply': 0.61; "you'll": 0.62; 'more': 0.64; 'importantly,': 0.68; 'it"': 0.84; 'results,': 0.84; 'silently': 0.84; 'to:none': 0.92 |
| 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=G8F54bq/3r/E5/hyOk/R8P2/sRQJmdFM/uY8WjL6oIA=; b=hYjoI62atWOO4Dw7FWmtwB1T3jbxtSzRG6mv7DT5zIgYbCv2oF2/+F4JM4wXaWhJiD Mnj5mw0kyn25T83UX+ekH6kO0vzED99hya4v7Ghwt6qWQxkZ73dn1ROw6F50CJuwL2WS NaGG9Qyvym8/89HF6Lcy9tfG/9gSCB5MXPxvK4Qvva93H5ZafNEmZ6dSdD/kTctdiTb8 aG57/rIFSJYogeaFV8Dko8AQcy14tOVLLbQ4CHaZN7IjKooCeBjP5gHZBN6wBlUwBpq9 xC2pQeZ50+0Vr3ZhZ2uk0t1HT+C57R5cAuHmZgQQQjMZXfLLkVpH1k4pM/07lneTGu+N fEnw== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.79.135 with SMTP id j7mr12248169igx.14.1417996239418; Sun, 07 Dec 2014 15:50:39 -0800 (PST) |
| In-Reply-To | <5484e3d8$0$13013$c3e8da3$5496439d@news.astraweb.com> |
| References | <004e01d01173$e1641c10$a42c5430$@gmail.com> <m61roh$i5m$1@ger.gmane.org> <CALwzid=79=i3Sez3fQYV7xU2bEAL4_ohPqxhuYj59Y5ihXk1Zg@mail.gmail.com> <mailman.16685.1417976998.18130.python-list@python.org> <5484e3d8$0$13013$c3e8da3$5496439d@news.astraweb.com> |
| Date | Mon, 8 Dec 2014 10:50:39 +1100 |
| Subject | Re: Python Iterables struggling using map() built-in |
| 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.15 |
| 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.16689.1417996247.18130.python-list@python.org> (permalink) |
| Lines | 35 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1417996247 news.xs4all.nl 2845 [2001:888:2000:d::a6]:52705 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:82082 |
Show key headers only | View raw
On Mon, Dec 8, 2014 at 10:33 AM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > How would we re-write this to work in the future Python 3.7? Unless I have > missed something, I think we could write it like this: > > def myzip37(*args): > iters = list(map(iter, args)) > while iters: > try: > yield tuple([next(i) for i in iters]) > except StopIteration: > return > > which I guess is not too horrible. It's not horrible, and there are other ways it could be written too, which also aren't horrible. Yes, it's not quite as short as the other version; but more importantly, it's explicit about how StopIteration affects it. It's clear that this exception, if raised by _any_ of the iterators (even after consuming values from some of them, perhaps), will silently terminate the generator. The current behaviour favours a handful of cases like this, although personally I think the termination of zip() is simply "this is what happens if we have no code here, so let's document it" rather than being something inherently ideal; the new behaviour favours the debugging of many obscure cases and some less-obscure ones as well. Most importantly, if you run the old version of myzip on Python 3.7, you'll get an immediate and noisy RuntimeError when it terminates, and you'll know exactly where to go fix stuff; if you run a buggy generator on Python 3.4, you simply see no more results, without any explanation of why. I'd rather debug the RuntimeError that can be easily and trivially fixed in 99% of cases. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Python Iterables struggling using map() built-in Chris Angelico <rosuav@gmail.com> - 2014-12-08 05:29 +1100
Re: Python Iterables struggling using map() built-in Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-08 10:33 +1100
Re: Python Iterables struggling using map() built-in Chris Angelico <rosuav@gmail.com> - 2014-12-08 10:50 +1100
Re: Python Iterables struggling using map() built-in Roy Smith <roy@panix.com> - 2014-12-07 19:27 -0500
Re: Python Iterables struggling using map() built-in Chris Angelico <rosuav@gmail.com> - 2014-12-08 11:35 +1100
Re: Python Iterables struggling using map() built-in Steven D'Aprano <steve@pearwood.info> - 2014-12-08 09:40 +0000
Re: Python Iterables struggling using map() built-in Chris Angelico <rosuav@gmail.com> - 2014-12-08 20:50 +1100
Re: Python Iterables struggling using map() built-in Roy Smith <roy@panix.com> - 2014-12-08 19:02 -0500
Re: Python Iterables struggling using map() built-in Roy Smith <roy@panix.com> - 2014-12-07 19:12 -0500
Re: Python Iterables struggling using map() built-in Chris Angelico <rosuav@gmail.com> - 2014-12-08 11:34 +1100
Re: Python Iterables struggling using map() built-in Roy Smith <roy@panix.com> - 2014-12-07 19:45 -0500
Re: Python Iterables struggling using map() built-in Chris Angelico <rosuav@gmail.com> - 2014-12-08 12:00 +1100
Re: Python Iterables struggling using map() built-in MRAB <python@mrabarnett.plus.com> - 2014-12-08 03:09 +0000
Re: Python Iterables struggling using map() built-in Terry Reedy <tjreedy@udel.edu> - 2014-12-07 19:38 -0500
Re: Python Iterables struggling using map() built-in Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-12-08 18:06 +1300
Re: Python Iterables struggling using map() built-in Ned Batchelder <ned@nedbatchelder.com> - 2014-12-07 20:06 -0500
Re: Python Iterables struggling using map() built-in Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-09 13:50 +1100
Re: Python Iterables struggling using map() built-in Terry Reedy <tjreedy@udel.edu> - 2014-12-09 00:03 -0500
Re: Python Iterables struggling using map() built-in Steven D'Aprano <steve@pearwood.info> - 2014-12-09 06:40 +0000
Re: Python Iterables struggling using map() built-in Terry Reedy <tjreedy@udel.edu> - 2014-12-09 15:06 -0500
Re: Python Iterables struggling using map() built-in Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-10 11:10 +1100
Re: Python Iterables struggling using map() built-in Chris Angelico <rosuav@gmail.com> - 2014-12-10 11:20 +1100
Re: Python Iterables struggling using map() built-in Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-12-10 00:24 +0000
Re: Python Iterables struggling using map() built-in Roy Smith <roy@panix.com> - 2014-12-09 21:44 -0500
Re: Python Iterables struggling using map() built-in Steven D'Aprano <steve@pearwood.info> - 2014-12-10 09:24 +0000
Re: Python Iterables struggling using map() built-in Chris Angelico <rosuav@gmail.com> - 2014-12-10 20:32 +1100
Re: Python Iterables struggling using map() built-in Marko Rauhamaa <marko@pacujo.net> - 2014-12-10 12:58 +0200
Re: Python Iterables struggling using map() built-in Ian Kelly <ian.g.kelly@gmail.com> - 2014-12-10 09:46 -0700
Re: Python Iterables struggling using map() built-in Steven D'Aprano <steve@pearwood.info> - 2014-12-11 04:01 +0000
Re: Python Iterables struggling using map() built-in Ian Kelly <ian.g.kelly@gmail.com> - 2014-12-11 15:00 -0700
Re: Python Iterables struggling using map() built-in Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-12 10:28 +1100
Re: Python Iterables struggling using map() built-in Ian Kelly <ian.g.kelly@gmail.com> - 2014-12-11 16:57 -0700
Re: Python Iterables struggling using map() built-in Roy Smith <roy@panix.com> - 2014-12-11 20:55 -0500
Re: Python Iterables struggling using map() built-in Ian Kelly <ian.g.kelly@gmail.com> - 2014-12-12 00:36 -0700
Re: Python Iterables struggling using map() built-in Chris Angelico <rosuav@gmail.com> - 2014-12-12 11:44 +1100
Re: Python Iterables struggling using map() built-in Terry Reedy <tjreedy@udel.edu> - 2014-12-10 12:48 -0500
Re: Python Iterables struggling using map() built-in Ian Kelly <ian.g.kelly@gmail.com> - 2014-12-10 13:32 -0700
Re: Python Iterables struggling using map() built-in Terry Reedy <tjreedy@udel.edu> - 2014-12-10 23:17 -0500
Re: Python Iterables struggling using map() built-in Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-12-08 18:00 +1300
csiph-web