Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'reason.': 0.07; 'received:verizon.net': 0.07; 'terry': 0.07; 'array.': 0.09; 'raised,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'thrown': 0.09; 'am,': 0.12; 'exception': 0.12; 'elements,': 0.16; 'iterator': 0.16; 'length,': 0.16; 'reedy': 0.16; 'subject:arrays': 0.16; 'wrote:': 0.16; 'jan': 0.19; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'slice': 0.23; 'raise': 0.28; "wasn't": 0.28; 'temporary': 0.29; 'values': 0.32; 'value.': 0.32; 'too': 0.33; 'to:addr:python-list': 0.33; 'done': 0.34; 'header :User-Agent:1': 0.34; 'test': 0.34; 'header:X-Complaints-To:1': 0.35; 'but': 0.37; 'something': 0.37; 'received:org': 0.38; 'steven': 0.38; 'should': 0.38; 'subject:: ': 0.39; 'header:Mime- Version:1': 0.39; 'why': 0.39; 'to:addr:python.org': 0.39; 'hope': 0.61; 'back': 0.62 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Assigning generator expressions to ctype arrays Date: Fri, 28 Oct 2011 04:19:26 -0400 References: <32ee8e3e-4d42-4d2e-bdc7-087970c2736e@hv4g2000vbb.googlegroups.com> <4ea9dbd0$0$29968$c3e8da3$5496439d@news.astraweb.com> <43aea5ad-bc9f-4e82-a9d5-74a06553a2ad@q16g2000yqn.googlegroups.com> <4eaa580a$0$29968$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-74-109-121-73.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20110812 Thunderbird/6.0 In-Reply-To: <4eaa580a$0$29968$c3e8da3$5496439d@news.astraweb.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1319789992 news.xs4all.nl 6873 [2001:888:2000:d::a6]:45101 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:15095 On 10/28/2011 3:21 AM, Steven D'Aprano wrote: > If the slice has too few elements, you've just blown away the entire > iterator for no good reason. > If the slice is the right length, but the iterator doesn't next raise > StopIteration, you've just thrown away one perfectly good value. Hope it > wasn't something important. You have also over-written values that should be set back to what they were, before the exception is raised, which is why I said the test needs to be done with a temporary array. -- Terry Jan Reedy