Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #69359

Re: checking if two things do not equal None

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 <rosuav@gmail.com>
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> <lh7cb4$ntu$2@news.albasani.net> <roy-B5E8CC.17072029032014@news.panix.com> <20140329173655.4022d715@bigbox.christie.dr> <F5F2BC07-AD55-46F1-970A-5BC49622677A@panix.com> <20140329174653.4969807f@bigbox.christie.dr> <CAPTjJmrJLpd-0YvScTteW7ApySr4hbvmwQixRw1Ht1O5UahuDg@mail.gmail.com> <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 <rosuav@gmail.com>
Cc "python-list@python.org" <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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.8708.1396143451.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Sun, Mar 30, 2014 at 12:19 PM, Tim Chase
<python.list@tim.thechases.com> wrote:
> On 2014-03-30 10:17, Chris Angelico wrote:
>> On Sun, Mar 30, 2014 at 9:46 AM, Tim Chase <tim@thechases.com>
>> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

checking if two things do not equal None contact.trigon@gmail.com - 2014-03-29 11:56 -0700
  Re: checking if two things do not equal None Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-29 19:05 +0000
    Re: checking if two things do not equal None contact.trigon@gmail.com - 2014-03-29 12:23 -0700
    Re: checking if two things do not equal None Lele Gaifax <lele@metapensiero.it> - 2014-03-29 20:24 +0100
    Re: checking if two things do not equal None Johannes Bauer <dfnsonfsduifb@gmx.de> - 2014-03-29 22:01 +0100
      Re: checking if two things do not equal None Roy Smith <roy@panix.com> - 2014-03-29 17:07 -0400
        Re: checking if two things do not equal None Johannes Bauer <dfnsonfsduifb@gmx.de> - 2014-03-29 22:55 +0100
          Re: checking if two things do not equal None Johannes Bauer <dfnsonfsduifb@gmx.de> - 2014-03-29 23:02 +0100
        Re: checking if two things do not equal None Dave Angel <davea@davea.name> - 2014-03-29 18:01 -0400
          Re: checking if two things do not equal None contact.trigon@gmail.com - 2014-03-29 16:20 -0700
        Re: checking if two things do not equal None Tim Chase <python.list@tim.thechases.com> - 2014-03-29 17:36 -0500
          Re: checking if two things do not equal None Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-30 02:24 +0000
            Re: checking if two things do not equal None Roy Smith <roy@panix.com> - 2014-03-29 22:43 -0400
              Re: checking if two things do not equal None Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-03-29 22:04 -0500
        Re: checking if two things do not equal None Roy Smith <roy@panix.com> - 2014-03-29 18:41 -0400
        Re: checking if two things do not equal None Tim Chase <tim@thechases.com> - 2014-03-29 17:46 -0500
          Re: checking if two things do not equal None Roy Smith <roy@panix.com> - 2014-03-29 18:51 -0400
        Re: checking if two things do not equal None Chris Angelico <rosuav@gmail.com> - 2014-03-30 10:17 +1100
        Re: checking if two things do not equal None Tim Chase <python.list@tim.thechases.com> - 2014-03-29 20:19 -0500
        Re: checking if two things do not equal None Chris Angelico <rosuav@gmail.com> - 2014-03-30 12:37 +1100
        Re: checking if two things do not equal None Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-30 02:04 +0000
          Re: checking if two things do not equal None Chris Angelico <rosuav@gmail.com> - 2014-03-30 13:15 +1100
            Re: checking if two things do not equal None Roy Smith <roy@panix.com> - 2014-03-29 22:39 -0400
              Re: checking if two things do not equal None Rustom Mody <rustompmody@gmail.com> - 2014-03-29 19:54 -0700
                Re: checking if two things do not equal None Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-30 06:08 +0000
                Re: checking if two things do not equal None Roy Smith <roy@panix.com> - 2014-03-30 08:21 -0400
                Re: checking if two things do not equal None MRAB <python@mrabarnett.plus.com> - 2014-03-30 14:58 +0100
                Re: checking if two things do not equal None Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-03-31 11:48 +1300
              Re: checking if two things do not equal None Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-03-30 19:41 +1300
                Re: checking if two things do not equal None Marko Rauhamaa <marko@pacujo.net> - 2014-03-30 10:37 +0300
            Re: checking if two things do not equal None Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-30 05:54 +0000
              Re: checking if two things do not equal None Chris Angelico <rosuav@gmail.com> - 2014-03-30 17:17 +1100
              Re: checking if two things do not equal None Ben Finney <ben+python@benfinney.id.au> - 2014-03-30 17:52 +1100
              Re: checking if two things do not equal None Chris Angelico <rosuav@gmail.com> - 2014-03-30 18:36 +1100
      Re: checking if two things do not equal None Ethan Furman <ethan@stoneleaf.us> - 2014-03-29 16:20 -0700
  Re: checking if two things do not equal None Terry Reedy <tjreedy@udel.edu> - 2014-03-29 19:02 -0400
  Re: checking if two things do not equal None Jeremy Sanders <jeremy@jeremysanders.net> - 2014-03-31 09:56 +0200
    Re: checking if two things do not equal None Abe <contact.trigon@gmail.com> - 2014-03-31 10:28 -0700
      Re: checking if two things do not equal None Moritz Emanuel Beber <moritz.beber@gmail.com> - 2014-03-31 21:22 +0200

csiph-web