On 06/15/2013 10:21 PM, Jim Mooney wrote:
On 15 June 2013 19:03, Dave Angel <da...@davea.name> wrote:
Why such a convoluted way of expressing yourself?

I was demonstrating the parallelism, but let's just take one so I can
unbefuddle meself ;')

*** Python 3.3.2 32 bit (Intel)] on win32. ***
'' == False
False
not ''
True


Why the difference here?


There's no contradiction;  you're doing two entirely different things.

If you want to compare a non-boolean to False or True, expect it'll always be false. They are different types. (except for the int historical nonsense I mentioned earlier).

If you want to duplicate what the second expression does, you'll have to convert the str to a boolean, using the bool() function.[1]

>>> bool("") == False
True

[1] Technically it's not a function but a "type" operation, or something. But it quacks like a function, and I can't be bothered, at least not for this discussion.

--
DaveA
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to