Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'value,': 0.03; 'none)': 0.07; 'loop.': 0.09; 'subject:while': 0.09; 'value.': 0.15; 'n),': 0.16; 'oct': 0.16; 'returned,': 0.16; 'select,': 0.16; 'skips': 0.16; 'subject:expression': 0.16; 'wrote:': 0.17; 'thu,': 0.17; 'header:In-Reply-To:1': 0.25; 'values': 0.26; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'received:209.85.215.46': 0.30; 'not.': 0.32; 'goes': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'thomas': 0.62; 'rachel': 0.84; 'to:name:python': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=p4x79KiI1NWqh1xB5hvcaCAx+jwJhzdqRKf9XiqLV8M=; b=hgC82I8oCmqwTdzhetBlw2SYULaOrMqXPj6NoQVkvFctzUqGfl9s27wUGLyyC0PGNY HT1KXuDtq6eX+XLrucX1R2kcLfVHnNT4NJTBsweiCqjPJ/Np43reZX6tredZSQR6Nynj lZee581Rz0Li8ExUn/U+c95mgywgTO8NfJrJpBHOEwZbGaLZRKDjqCR2vDZ/7axqxFM6 yny1HgXI8rzXu5xkKuigw9+kCAcr9DW6nuwX9nMdc2hC0neNx7qB32tO6QudVmKtzWIs Tg7pMNKysfRSMd0EjeYS9T1Gk1hn8/3W8qX0tLlKQhbr9/ovrdOmr9CApDptF5ZFgYnG 0cIg== MIME-Version: 1.0 In-Reply-To: References: <50886398.5050301@tim.thechases.com> <7x7gqf1na2.fsf@ruckus.brouhaha.com> From: Ian Kelly Date: Thu, 25 Oct 2012 10:36:47 -0600 Subject: Re: while expression feature proposal To: Python Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351183039 news.xs4all.nl 6873 [2001:888:2000:d::a6]:54762 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32145 On Thu, Oct 25, 2012 at 1:21 AM, Thomas Rachel wrote: >> j = next(j for j in iter(partial(randrange, n), None) if j not in >> selected) > > > This generator never ends. If it meets a non-matching value, it just skips > it and goes on. next() only returns one value. After it is returned, the generator is discarded, whether it has ended or not. If there were no valid values for randrange to select, then it would descend into an infinite loop. But then, so would the dropwhile and the original while loop.