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
> 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
Aucun commentaire:
Enregistrer un commentaire