Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.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.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'say,': 0.05; 'mask': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'jan': 0.12; "wouldn't": 0.14; '6:00': 0.16; 'pythonic': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'x),': 0.16; 'thursday,': 0.16; 'wrote:': 0.18; 'do.': 0.18; 'trying': 0.19; '>>>': 0.22; 'appears': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; '31,': 0.24; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'code': 0.31; 'yes.': 0.31; 'this.': 0.32; 'probably': 0.32; 'fri,': 0.33; "i'd": 0.34; 'problem': 0.35; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'should': 0.36; 'january': 0.37; 'wrong': 0.37; 'list': 0.37; 'to:addr:python-list': 0.38; 'list,': 0.38; 'pm,': 0.38; 'that,': 0.38; 'anything': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'solve': 0.60; 'received:173': 0.61; 'more': 0.64; '30,': 0.65; 'received:fios.verizon.net': 0.84; 'so...': 0.84; 'subject:Statement': 0.91; 'subject:True': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Statement evals as False in my IDE and True elsewhere Date: Fri, 31 Jan 2014 00:09:19 -0500 References: <5673ebd0-89b6-485c-8ccb-f62bf15f513a@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-254-207.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: <5673ebd0-89b6-485c-8ccb-f62bf15f513a@googlegroups.com> 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391145004 news.xs4all.nl 2924 [2001:888:2000:d::a6]:52534 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65092 On 1/30/2014 6:00 PM, CM wrote: > On Thursday, January 30, 2014 5:25:31 PM UTC-5, Chris Angelico wrote: >> On Fri, Jan 31, 2014 at 9:04 AM, CM wrote: >> >>> fake_data = ['n/a', 'n/a', 'n/a', 'n/a', '[omitted]', '12'] >> >>> fake_result = not all(i == '[omitted]' for i in fake_data) >> Trying to get my head around this. You want to see if all the values >> in fake_data are '[omitted]' or not? That is to say, if there's >> anything that isn't '[omitted]'? Not sure that that's a normal thing >> to be asking, but that's what your code appears to do. > > That's what I want, yes. It probably sure isn't a normal thing to be asking, and I wouldn't be surprised if I am approaching it the wrong way. Essentially, if ALL the items in that list are '[omitted]', I must not process the list, but if even one of them is something other than '[omitted]', I need to process it. > > If there is a more Pythonic / better way to approach that, I'd like to know it. not all(x) == any(not x), so... any(i != '[omitted]' for i in fake_data) While nothing you import should *ever* mask a builtin, this would also solve the all problem -- Terry Jan Reedy