Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed4a.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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:not': 0.03; 'subsequent': 0.05; 'subject:two': 0.07; 'calls.': 0.09; 'iterate': 0.09; 'subject:None': 0.09; 'cc:addr:python-list': 0.11; '^^^': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iteration': 0.16; 'met.': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'cheap': 0.19; '>>>': 0.22; 'tests': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply- To:1': 0.27; 'function': 0.29; 'correct': 0.29; 'chris': 0.29; 'am,': 0.29; 'tim': 0.29; 'message-id:@mail.gmail.com': 0.30; 'chase': 0.31; 'checking': 0.33; 'possible.': 0.35; 'something': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'doing': 0.36; 'useful': 0.36; 'behind': 0.37; 'list': 0.37; 'mine': 0.38; 'list,': 0.38; 'pm,': 0.38; 'save': 0.62; '30,': 0.65; 'mar': 0.68; 'anything.': 0.68; 'costly': 0.84; 'presumably': 0.84; 'to:none': 0.92 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:cc :content-type; bh=+fyDvrz2naoOXtkGIukqn2dnLr8kwjow9Oe+0YKWWh0=; b=M1dKEvv+q/rxyRbQX1o65r9CAraqN8uD4AAS7JY616FfKfUR+e0/yxqXpKr/5DQG2H TPvR05WKX+FQICinVgo7gvuQ2ShfDjFjzpfY3jMSfl4+O8eGDtlunz7ps6V38ktMgkZG N+dVXnocHmzrtNUpZurbKHCGnvc6vqPJ0uyeNYZrX0WZVEqFNziHKzkOJNvZLrlehFuk ACPN9OuXsPtBBkaWtelZxal+SuhlQA8ksF+MKbhS0T5janLtpdqMvllScbcQHw4OakIM BxMlnGmDGQXF9EbPuFHeJEoHvEnndxB7CqCn5REtXQF2yo8lncy+RqyzSb1uSpYzsrJo xWlw== MIME-Version: 1.0 X-Received: by 10.68.110.165 with SMTP id ib5mr17006703pbb.61.1396143448674; Sat, 29 Mar 2014 18:37:28 -0700 (PDT) In-Reply-To: <20140329201906.4beab393@bigbox.christie.dr> References: <0245aca0-c6b7-493a-aa52-2c3ef6462dbd@googlegroups.com> <5337195f$0$29994$c3e8da3$5496439d@news.astraweb.com> <20140329173655.4022d715@bigbox.christie.dr> <20140329174653.4969807f@bigbox.christie.dr> <20140329201906.4beab393@bigbox.christie.dr> Date: Sun, 30 Mar 2014 12:37:28 +1100 Subject: Re: checking if two things do not equal None From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1396143451 news.xs4all.nl 2842 [2001:888:2000:d::a6]:40853 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69359 On Sun, Mar 30, 2014 at 12:19 PM, Tim Chase wrote: > On 2014-03-30 10:17, Chris Angelico wrote: >> On Sun, Mar 30, 2014 at 9:46 AM, Tim Chase >> wrote: >>> Though am I correct that your iteration tests for equality, while >>> mine tests for identity? Also, my version bails early in the >>> event quitting early is possible. That's particularly useful in >>> the case of doing something like >>> >>> if all(x() is None for x in [func1, func2, func3, costly_func]): > ^^^ >>> do_something() >> >> Presumably you mean to actually call those functions, as checking >> the identity of a costly function is still cheap :) > > Which is what I do...calling only those necessary until the all/any > condition has been met. :-) > > If you create the list of things to iterate over by calling them as > you create the list, then you don't save much of anything. If you > only call until one of them breaks the any/all construct, you save > all the subsequent function calls. *facepalm* Yep, you do indeed. My bad! Take no notice of the man behind the curtain... ChrisA