Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #104168
| Path | csiph.com!feeder.erje.net!2.eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | MRAB <python@mrabarnett.plus.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: reversed(zip(...)) not working as intended |
| Date | Sun, 6 Mar 2016 19:00:51 +0000 |
| Lines | 21 |
| Message-ID | <mailman.266.1457291042.20602.python-list@python.org> (permalink) |
| References | <56DC7727.1090001@mail.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de 3frFhMsjouddkInGNLjwaQ9ZJk9pyOhUp6bMMRLw0GSA== |
| Return-Path | <python@mrabarnett.plus.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'raises': 0.07; 'subject:not': 0.11; 'explicitly': 0.15; 'complain,': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'iterator': 0.16; 'iterator.': 0.16; 'iterators': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'reversed': 0.16; 'wrote:': 0.16; 'first.': 0.18; 'leave': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'order.': 0.27; 'yield': 0.27; 'yields': 0.29; 'related': 0.32; 'handle': 0.34; 'item': 0.35; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; "won't": 0.38; 'hi,': 0.38; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'strange': 0.63; 'reverse': 0.66 |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.1 cv=K//fZHiI c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=IkcTkHD0fZMA:10 a=fklf6JiOu5FyOZnqUl0A:9 a=QEXdDO2ut3YA:10 |
| X-AUTH | mrabarnett@:2500 |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 |
| In-Reply-To | <56DC7727.1090001@mail.de> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21 |
| 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> |
| Xref | csiph.com comp.lang.python:104168 |
Show key headers only | View raw
On 2016-03-06 18:29, Sven R. Kunze wrote: > Hi, > > what's the reason that reversed(zip(...)) raises as a TypeError? > > Would allowing reversed to handle zip and related functions lead to > strange errors? > 'reversed' yields the items in reverse order; it needs the last item first. Iterators yield items from the first to the last. 'reversed' would have to get and store all of the items from the iterator. It won't know which is the last item until the iterator raises StopIteration. Only then will it be able to yield the items in reverse order. It's much better for it to complain, and leave it for the user to do it explicitly with reversed(list(zip(...))).
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: reversed(zip(...)) not working as intended MRAB <python@mrabarnett.plus.com> - 2016-03-06 19:00 +0000
csiph-web