This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ezio.melotti
Recipients ezio.melotti, the_iain
Date 2011-04-01.14:35:00
SpamBayes Score 2.5495416e-05
Marked as misclassified No
Message-id <1301668500.83.0.0910925174194.issue11737@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2011-04-01 14:35:00ezio.melottisetrecipients: + ezio.melotti, the_iain
2011-04-01 14:35:00ezio.melottisetmessageid: <1301668500.83.0.0910925174194.issue11737@psf.upfronthosting.co.za>
2011-04-01 14:35:00ezio.melottilinkissue11737 messages
2011-04-01 14:35:00ezio.melotticreate