Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'syntax': 0.03; 'explicitly': 0.04; 'string.': 0.04; 'none,': 0.05; 'none:': 0.05; 'expressions': 0.07; 'python': 0.09; 'bool': 0.09; 'received:mail- vc0-f174.google.com': 0.09; 'subject:while': 0.09; 'cases': 0.15; '"none"': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'oct': 0.16; 'subject:expression': 0.16; 'string': 0.17; 'wrote:': 0.17; 'odd': 0.17; 'supposed': 0.21; 'assignment': 0.22; 'implicit': 0.22; 'paul': 0.24; 'header:In- Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'skip:( 20': 0.28; 'dan': 0.29; 'received:209.85.220.174': 0.29; 'writes:': 0.29; 'case,': 0.29; 'probably': 0.29; 'fri,': 0.30; '(and': 0.32; 'print': 0.32; 'to:addr:python-list': 0.33; 'everyone': 0.33; 'received:google.com': 0.34; 'false': 0.35; 'doing': 0.35; 'pm,': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'client': 0.36; 'test': 0.36; 'should': 0.36; 'why': 0.37; 'rather': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'end': 0.40; 'worth': 0.63; 'more': 0.63; '26,': 0.65; 'seriously,': 0.91; 'write:': 0.91 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:to :content-type; bh=p2NzriykgFlQpeRDjSUow8PpO1PxT0Uo+c1p8JGu/g8=; b=D3+9QFac8U+mUzJAB7NGIAxAyEqjPMSX/xvYT08o2FBCcqw7YdJbw3WTiY1oORLi/N kXqmvOfZrgJHRofJ/IgWusnPbcXLHY7e32mj67ZKSm1JndEnySUY1r2XU7fd5xohY2ZP jx8a9Z5nGMDlCKW0vutiwaHVmsMNXnO8qZgX4Lp6gY5Uyu/tzo0UuPKAopEWY4rkqGAx Ix6x201KXaAnn222nFl4MI9GI7h9xmDdgSbE1J2kr3Cazb3Au7nqNpacvDk4tdCy1359 oCyDmDQISnSB5eu/OPZ5paDzoxei8HMzor//4hEIMB1pzHU9xYJAWVdIZKAh6KFix9WM Qc4A== MIME-Version: 1.0 In-Reply-To: <7x7gqdzs1i.fsf@ruckus.brouhaha.com> References: <50886398.5050301@tim.thechases.com> <7x7gqf1na2.fsf@ruckus.brouhaha.com> <7x7gqdzs1i.fsf@ruckus.brouhaha.com> Date: Fri, 26 Oct 2012 17:23:12 +1100 Subject: Re: while expression feature proposal From: Chris Angelico To: python-list@python.org 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351232595 news.xs4all.nl 6844 [2001:888:2000:d::a6]:59886 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32197 On Fri, Oct 26, 2012 at 5:06 PM, Paul Rubin wrote: > Dan Loewenherz writes: >> In this case, profile_id is "None" when the loop breaks. It would be >> much more straightforward (and more Pythonic, IMO), to write: >> >> client = StrictRedis() >> while client.spop("profile_ids") as profile_id: >> print profile_id > > That is pretty loose, in my opinion. If the loop is supposed to return > a string until breaking on None, the break test should explicitly check > for None rather than rely on an implicit bool conversion that will also > test as false on an empty string. while (client.spop("profile_ids") as profile_id) is not None: print profile_id Why is everyone skirting around C-style assignment expressions as though they're simultaneously anathema and the goal? :) But seriously, this new syntax would probably enhance Python somewhat, but you're going to end up with odd edge cases where it's just as almost-there as current syntax is for what this will solve. Is it worth doing half the job? ChrisA