Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:not': 0.03; 'subject:two': 0.07; 'none)': 0.09; 'none):': 0.09; 'subject:None': 0.09; 'cc:addr:python-list': 0.11; '(none,': 0.16; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'readable': 0.16; 'roy': 0.16; 'wrote:': 0.18; 'seems': 0.21; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'easier': 0.31; 'that.': 0.31; 'too.': 0.31; 'view.': 0.31; 'cases': 0.33; 'skip:d 20': 0.34; 'could': 0.34; 'agree': 0.35; 'test': 0.35; 'but': 0.35; 'charset:us-ascii': 0.36; 'two': 0.37; 'skip:u 10': 0.60; 'more': 0.64; 'smith': 0.68; 'fact,': 0.69; 'received:50.22': 0.84 Date: Sat, 29 Mar 2014 17:36:55 -0500 From: Tim Chase To: Roy Smith Subject: Re: checking if two things do not equal None In-Reply-To: References: <0245aca0-c6b7-493a-aa52-2c3ef6462dbd@googlegroups.com> <5337195f$0$29994$c3e8da3$5496439d@news.astraweb.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Get-Message-Sender-Via: boston.accountservergroup.com: authenticated_id: tim@thechases.com Cc: python-list@python.org 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1396132615 news.xs4all.nl 2903 [2001:888:2000:d::a6]:37988 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69350 On 2014-03-29 17:07, Roy Smith wrote: > > if (a is not None) or (b is not None): > > > > is immediately understandable by everyone? > > I agree with that. But > > > if (a, b) != (None, None): > > seems pretty straight-forward to me too. In fact, if anything, it > seems easier to understand than And for cases where you have more than one or two things to test for None-itude, you could use if all(x is None for x in [a, b, c, d]): do_something_if_theyre_all_None() or if all(x is not None for x in [a, b, c, d]): do_something_if_no_Nones() or if not any(x is None for x in [a, b, c, d]): do_something_if_no_Nones() which I find *much* more readable from a maintenance point of view. -tkc