[Tutor] Boolean question

Alan Gauld alan.gauld at btinternet.com
Wed Mar 16 23:41:02 CET 2011


"Donald Bedsole" <drbedsole at gmail.com> wrote

>> False or thing = thing
>>
> Thanks for your response and for  the rules, but for some reason I'm
> not understanding.  In the above quote, what is meant by "thing"?

Any Boolean value, and in Python that means pretty much
anything at all because Python has a set of rules over how
it converts values to booleans.

More or less it is that:
None, empty strings, lists etc , zero, are all False,
anything else is True

You can check by explicitly converting:

spam = "foo"  # or any other value
print bool(spam)

HTH,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list