<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
goldtech wrote:
<blockquote
cite="mid:10da5db0-ba83-42a1-8ce8-95d13b513ca1@v15g2000prn.googlegroups.com"
type="cite">
<pre wrap="">Could you explain or link me to an explanation of this? Been using
Python for a while but not sure I understand what's happening below.
Thanks.
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">ss=1 and "fffff"
ss
</pre>
</blockquote>
</blockquote>
</blockquote>
<pre wrap=""><!---->'fffff'
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">ss=0 and "fffff"
ss
</pre>
</blockquote>
</blockquote>
</blockquote>
<pre wrap=""><!---->0
</pre>
</blockquote>
<br>
Python's Boolean operators don't turn arbitrary values into True and
False values. If you use it in any conditional, you'll get the same
result as if it did, but it is occasionally it's nice to get the actual
values used in the "and" instead of having the value distilled down to
a True/False.<br>
<br>
<br>
>From the Python manual: <br>
<p>These are the Boolean operations, ordered by ascending priority:
</p>
<p></p>
<div class="center">
<table class="realtable">
<thead> <tr>
<th class="center">Operation</th>
<th class="left">Result</th>
<th class="center">Notes</th>
</tr>
</thead> <tbody>
<tr>
<td class="center" valign="baseline"><code><var>x</var> or <var>y</var></code></td>
<td class="left">if <var>x</var> is false, then <var>y</var>,
else <var>x</var></td>
<td class="center">(1)</td>
</tr>
<tr>
<td class="center" valign="baseline"><code><var>x</var> and <var>y</var></code></td>
<td class="left">if <var>x</var> is false, then <var>x</var>,
else <var>y</var></td>
<td class="center">(1)</td>
</tr>
<tr>
<td class="center" valign="baseline"><code>not <var>x</var></code></td>
<td class="left">if <var>x</var> is false, then <code>True</code>,
else <code>False</code></td>
<td class="center">(2)</td>
</tr>
</tbody>
</table>
</div>
<p>
Notes:
</p>
<p></p>
<dl>
<dt><strong>(1)</strong></dt>
<dd>These only evaluate their second argument if needed for their
outcome.
<p></p>
</dd>
<dt><strong>(2)</strong></dt>
<dd>"<tt class="samp">not</tt>" has a lower priority than non-Boolean
operators, so
<code>not <var>a</var> == <var>b</var></code> is interpreted as <code>not
(<var>a</var> ==
<var>b</var>)</code>, and <code><var>a</var> == not <var>b</var></code>
is a syntax error.
<p></p>
</dd>
</dl>
<p>
</p>
<hr>
</body>
</html>