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


Groups > comp.lang.python > #65056

Re: Statement evals as False in my IDE and True elsewhere

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.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.057
X-Spam-Evidence '*H*': 0.89; '*S*': 0.00; 'say,': 0.05; 'cc:addr :python-list': 0.11; 'jan': 0.12; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.18; 'do.': 0.18; 'trying': 0.19; 'pieces': 0.19; 'appears': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'this?': 0.23; '31,': 0.24; 'cc:2**0': 0.24; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; "skip:' 10": 0.31; 'this.': 0.32; 'fri,': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'that,': 0.38; 'anything': 0.39; 'sure': 0.39; 'entire': 0.61; "you'll": 0.62; 'show': 0.63; 'between': 0.67; 'divide': 0.84; 'subject:Statement': 0.91; 'subject:True': 0.91; '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=Isqa+9nW28vnNuk3jBScBJ6fvQEunrVwrXV449BW0qo=; b=V+M36ZT940MCMBUWF/hn9ZrHoJmEJI5XI+sBubhyllAbR5fAryVflm5QkvFEaarZ6J a91iHSG5ofZi+QCCEl5wIwKlcLle8yh6ejOBWIVMhzNuIY408Z6/f15TkhxROGxu+hyq H62yQ6zmJODAedKAVTjstHgxCv9SquvcJRr8ZGfcV+aJS7sE/Sk3UxeTyF/FIGVsgElQ tWR3QZLsOCNXMVTTdIxhwEM8pCoKhnauGH0jvYOZB4IS38GgPklzxqytWMQNL8dCZhx4 /M+/R6vOZihDakPs2CjQMzN8rU0LYlBlwWqrKP2D329Bn1HQ5caAxcsgf0DXSNskEPyY wh7A==
MIME-Version 1.0
X-Received by 10.66.164.229 with SMTP id yt5mr17215577pab.67.1391120732031; Thu, 30 Jan 2014 14:25:32 -0800 (PST)
In-Reply-To <a543e1a5-ef00-42b0-96df-5bf9ee8ac74c@googlegroups.com>
References <a543e1a5-ef00-42b0-96df-5bf9ee8ac74c@googlegroups.com>
Date Fri, 31 Jan 2014 09:25:31 +1100
Subject Re: Statement evals as False in my IDE and True elsewhere
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.6171.1391121221.18130.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1391121221 news.xs4all.nl 2901 [2001:888:2000:d::a6]:37450
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:65056

Show key headers only | View raw


On Fri, Jan 31, 2014 at 9:04 AM, CM <cmpython@gmail.com> wrote:
>     fake_data = ['n/a', 'n/a', 'n/a', 'n/a', '[omitted]', '12']
>     fake_result = not all(i == '[omitted]' for i in fake_data)
>     print 'This is fake result: ', fake_result

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.

What happens if you try this?

fake_data = ['n/a', 'n/a', 'n/a', 'n/a', '[omitted]', '12']
fake_result = set(fake_data)>{'[omitted]'}

In theory, that should do the exact same thing as your code (returning
True if there's anything in fake_data that is not '[omitted]').

The other thing to try is peppering your code with print statements.
Divide the work up into pieces - show the entire loop and what happens
- print out everything you can imagine. See where the difference
begins between inside and outside the IDE. Once you find that, you'll
have a clue as to what's wrong.

ChrisA

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


Thread

Statement evals as False in my IDE and True elsewhere CM <cmpython@gmail.com> - 2014-01-30 14:04 -0800
  Re: Statement evals as False in my IDE and True elsewhere Peter Otten <__peter__@web.de> - 2014-01-30 23:14 +0100
    Re: Statement evals as False in my IDE and True elsewhere CM <cmpython@gmail.com> - 2014-01-30 14:48 -0800
      Re: Statement evals as False in my IDE and True elsewhere Chris Angelico <rosuav@gmail.com> - 2014-01-31 09:55 +1100
        Re: Statement evals as False in my IDE and True elsewhere CM <cmpython@gmail.com> - 2014-01-30 15:02 -0800
      Re: Statement evals as False in my IDE and True elsewhere Peter Otten <__peter__@web.de> - 2014-01-31 00:08 +0100
      Re: Statement evals as False in my IDE and True elsewhere Terry Reedy <tjreedy@udel.edu> - 2014-01-31 00:05 -0500
      Re: Statement evals as False in my IDE and True elsewhere Chris Angelico <rosuav@gmail.com> - 2014-01-31 16:07 +1100
  Re: Statement evals as False in my IDE and True elsewhere Chris Angelico <rosuav@gmail.com> - 2014-01-31 09:25 +1100
    Re: Statement evals as False in my IDE and True elsewhere CM <cmpython@gmail.com> - 2014-01-30 15:00 -0800
      Re: Statement evals as False in my IDE and True elsewhere Chris Angelico <rosuav@gmail.com> - 2014-01-31 10:25 +1100
      Re: Statement evals as False in my IDE and True elsewhere Terry Reedy <tjreedy@udel.edu> - 2014-01-31 00:09 -0500

csiph-web