How to work "if np.array([False]):"
<p>The output of the following code is <strong>NOTHING</strong>.</p>

<pre><code>if np.array([False]):
  print("hello")
</code></pre>

<p>Although I tried to search for it, I don't know how it works. Can Python overload <code>if</code>? </p>

<p>The following is a case of a pure array.</p>

<pre><code>if [False]:
  print("hello")
</code></pre>

<p>The output is <code>hello</code></p>

<p>Would you tell me how to code np.array?</p>

<p>It seems np.array([]) returns False and so do for <code>0</code> and <code>False</code></p>

<pre><code>&gt;&gt;&gt; bool(np.array([]))
False
&gt;&gt;&gt; bool(np.array([0]))
False
&gt;&gt;&gt; bool(np.array([False]))
False
</code></pre>

<p>Here the list returns true if it has any item..</p>

<pre><code>&gt;&gt;&gt; bool([False])   ### the returned boolean value is based on the length of the list.
True
</code></pre>

python numpy