Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #65056
| References | <a543e1a5-ef00-42b0-96df-5bf9ee8ac74c@googlegroups.com> |
|---|---|
| Date | 2014-01-31 09:25 +1100 |
| Subject | Re: Statement evals as False in my IDE and True elsewhere |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.6171.1391121221.18130.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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