Ezio Melotti <ezio.melo...@gmail.com> added the comment:

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

----------
nosy: +ezio.melotti
resolution:  -> invalid
stage:  -> committed/rejected
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11737>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to