Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!xlned.com!feeder7.xlned.com!news2.euro.net!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.030 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'none)': 0.07; 'expression:': 0.09; 'subject:while': 0.09; '24,': 0.16; 'itertools': 0.16; 'n),': 0.16; 'oct': 0.16; 'reasonably': 0.16; 'subject:expression': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'trying': 0.21; 'bit': 0.21; 'import': 0.21; 'do.': 0.21; 'paul': 0.24; 'header:In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'received:209.85.215.46': 0.30; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'think': 0.40; 'kind': 0.61; 'more': 0.63; 'wish': 0.70; 'expresses': 0.84; 'nice,': 0.84; 'to:name:python': 0.84; 'ugly,': 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=avI8rvlct7x0K1x9Cvtsq7NSV3VnPKv79KKnvp18WCE=; b=sQknb6ejbl6czQZyP5cBIAiJ3wYajkXjUuZdHi9De2fNggYM88qL7uzhBm64X0Xgbj Gd1VzJA6jxOBFQZG4Z5hl7HQTipYDx7T7oM7YhyLeLOSXSQqBxfEB0+DvEETfJ02GpVz Wpmz+J4hycFHPInBQoECFZaKkK6jKTXjmORXeqI41Yxu6vlv0XPa88wGc0Eg8/Ku9EDG iYDS1OGryWObTqwazs6PqAlW70dywZt/fu8p7ypZa8vlkbNcRbcIKj/SjXoNNSaZWU0a H/mGYMRbsnaVZL3hsmdwOp4CmsRfk/neY23CR+fepk3PZXU/Z4rJrsw2yGFqvnrwvv8v b4hQ== MIME-Version: 1.0 In-Reply-To: <7x7gqf1na2.fsf@ruckus.brouhaha.com> References: <50886398.5050301@tim.thechases.com> <7x7gqf1na2.fsf@ruckus.brouhaha.com> From: Ian Kelly Date: Wed, 24 Oct 2012 17:39:16 -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: 13 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351121989 news.xs4all.nl 6963 [2001:888:2000:d::a6]:58688 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32082 On Wed, Oct 24, 2012 at 5:08 PM, Paul Rubin wrote: > from itertools import dropwhile > > j = dropwhile(lambda j: j in selected, > iter(lambda: int(random() * n), object())) > .next() > > kind of ugly, makes me wish for a few more itertools primitives, but I > think it expresses reasonably directly what you are trying to do. Nice, although a bit opaque. I think I prefer it as a generator expression: j = next(j for j in iter(partial(randrange, n), None) if j not in selected)