Steven D'Aprano wrote:
On Mon, 27 Apr 2009 23:11:11 -0700, Aaron Brady wrote:
... In a boolean (or truth) context, Something and Nothing behave like True
> and False in languages with real booleans:
if obj:
    print "I am Something"
else:
    print "I am Nothing"

If you define the short-circuit boolean operators "and" and "or" as
Python does, the idea of "most anything is True" menas you can have
code that does:
    v = look('here') or look('there') or look('everywhere') or default

This is a nice idiom, and the "or default" can be used in lots of cases.

--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to