Why does '' apparently evaluate as True in Python
<p>I have:</p>

<pre><code>raw_matrix.append([])
for as_string in ' '.split(line):
    if as_string:
        print('as_string: #' + as_string + '#')
        raw_matrix[-1].append(int(as_string))
</code></pre>

<p>This produces the output:</p>

<pre><code>as_string: # #
Traceback (most recent call last):
  File "product_of_four", line 27, in &lt;module&gt;
    raw_matrix[-1].append(int(as_string))
ValueError: invalid literal for int() with base 10: ''
</code></pre>

<p>raw_matrix is a 20x20 array of lines of two digit (decimal) numbers separated by spaces.</p>

<p>If I'm reading this correctly, as_string is evaluating to ' ' or '', and I'm getting an exception as a side effect of as_string not being parseable as the side effect of it not containing an int()-parseable digit string.</p>

<p>How can I change things so that Python 2.x (3.x) parses a string of two-digit integers, rather than trying to parse unparseable strings as integers?</p>

<p>Thanks,</p>
