Message132741
The doc[0] says:
"""
x and y: if x is false, then x, else y
"""
Boolean operators in Python always return one of the two values (rather than True/False), and they are also short-circuit operators, so:
* if x is false, the whole expression is false regardless of the value of y, so x is returned without evaluating y;
* if x is true, y could be either:
* true: so the whole expression is true and y is returned;
* false: so the whole expression is false and y is returned;
>>> '' and True
''
>>> True and ''
''
>>> True and 15
15
The behavior matches the documentation and (False and True) returns False, because x (False in this case) is false.
[0]: http://docs.python.org/library/stdtypes.html#boolean-operations-and-or-not |
|
Date |
User |
Action |
Args |
2011-04-01 14:35:00 | ezio.melotti | set | recipients:
+ ezio.melotti, the_iain |
2011-04-01 14:35:00 | ezio.melotti | set | messageid: <1301668500.83.0.0910925174194.issue11737@psf.upfronthosting.co.za> |
2011-04-01 14:35:00 | ezio.melotti | link | issue11737 messages |
2011-04-01 14:35:00 | ezio.melotti | create | |
|