En Sat, 31 Jan 2009 10:16:19 -0200, AJ Ostergaard <a...@cubbyhole.net> escribió:

Hi Ralf,

Thanks for that but why:

 >>> '' and True
''

Surely that should be False?!?

Python does "short-circuit evaluation" [1]
"and" and "or" return one of its operands as soon as the outcome is determined, not just True or False.
'' is a false value, as false as False itself :)
After seeing that, there is no point in evaluating the second operand (True) because the final result cannot be true; so Python just returns the first operand.

[1] http://en.wikipedia.org/wiki/Short_circuit_evaluation

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to