About Truthiness and the Booleans True and False
<p>My environment is : ubuntu 16.04  &amp; python 2.7.12.</p>

<p>I read the documentation and found out that <code>''</code>, <code>()</code>, <code>[]</code>, <code>{}</code>, and <code>None</code> are all considered <code>False</code> by default.</p>

<p>But I don't understand what's going on in the examples below:</p>

<pre class="lang-none prettyprint-override"><code>Python 2.7.12 (default, Jul  1 2016, 15:12:24)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; a=''
&gt;&gt;&gt; a==False
False
&gt;&gt;&gt; a==True
False
&gt;&gt;&gt; a=bool(a)
&gt;&gt;&gt; a==False
True
&gt;&gt;&gt;
&gt;&gt;&gt;
&gt;&gt;&gt;
&gt;&gt;&gt; a="abcdefg"
&gt;&gt;&gt; a==True
False
&gt;&gt;&gt; a==False
False
&gt;&gt;&gt; a=bool(a)
&gt;&gt;&gt; a==True
True
&gt;&gt;&gt;
</code></pre>

<p>I want get the right result and it appears I must use the <code>bool()</code> function to do so.
Is that correct and why?</p>

<p>It's not that those values <em>are equal to</em> <code>False</code>, it's that they <em>behave</em> as false when used in a boolean context.</p>

<p>It's certainly proper to cast to <code>bool</code> if you absolutely need a value of <code>True</code> or <code>False</code>, but in most cases it's not necessary.</p>

python