home *** CD-ROM | disk | FTP | other *** search
- <TITLE>Boolean Operations -- Python library reference</TITLE>
- Next: <A HREF="../c/comparisons" TYPE="Next">Comparisons</A>
- Prev: <A HREF="../t/truth_value_testing" TYPE="Prev">Truth Value Testing</A>
- Up: <A HREF="../t/types" TYPE="Up">Types</A>
- Top: <A HREF="../t/top" TYPE="Top">Top</A>
- <H2>2.1.2. Boolean Operations</H2>
- These are the Boolean operations, ordered by ascending priority:
- <DL>
- <DT><I>Operation</I><DD><I>Result</I> --- <I>Notes</I>
- <P>
- <DT><CODE><VAR>x</VAR> or <VAR>y</VAR></CODE><DD>if <VAR>x</VAR> is false, then <VAR>y</VAR>, else <VAR>x</VAR> --- (1)
- <DT><CODE><VAR>x</VAR> and <VAR>y</VAR></CODE><DD>if <VAR>x</VAR> is false, then <VAR>x</VAR>, else <VAR>y</VAR> --- (1)
- <DT><CODE>not <VAR>x</VAR></CODE><DD>if <VAR>x</VAR> is false, then <CODE>1</CODE>, else <CODE>0</CODE> --- (2)
- </DL>
- Notes:
- <P>
- <DL>
- <DT><B>(1)</B><DD>These only evaluate their second argument if needed for their outcome.
- <P>
- <DT><B>(2)</B><DD>`<SAMP>not</SAMP>' has a lower priority than non-Boolean operators, so e.g.
- <CODE>not a == b</CODE> is interpreted as <CODE>not(a == b)</CODE>, and
- <CODE>a == not b</CODE> is a syntax error.
- <P>
- </DL>
-