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


Groups > comp.lang.python > #65054

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

From Peter Otten <__peter__@web.de>
Subject Re: Statement evals as False in my IDE and True elsewhere
Date 2014-01-30 23:14 +0100
Organization None
References <a543e1a5-ef00-42b0-96df-5bf9ee8ac74c@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.6169.1391120094.18130.python-list@python.org> (permalink)

Show all headers | View raw


CM wrote:

> This is puzzling.  (Using Python 2.5, WinXP, Boa Constructor 0.6.1
> definitely running the code through Python 2.5)
> 
> If I run these lines in my program, through my IDE (Boa Constructor),
> 
>     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
> 
> I get this result:
> 
>>>> 
> This is fake result:  False
> 
> BUT, if I run those *exact same lines* (copied and pasted) in the Python
> 2.5 shell within Boa Constructor, or with IDLE with Python 2.5, I get:
> 
>>>> 
> This is fake result:  True
> 
> ...which is what it seems like it should evaluate to, right?  What the
> heck is going on?  How is this even possible?  There is nothing that I
> know of in my code to cause this change, but perhaps there is.  Otherwise
> I am at a total loss.

Hint:

>>> def demo():
...     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
... 
>>> demo()
This is fake result:  True
>>> from numpy import all
>>> demo()
This is fake result:  False

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