Is it possible to check that a list is not empty before grabbing the first element using as few lines as possible in Python?
<p>I keep having to do this operation all over the place in my python code. I'm willing to bet there is an easier (aka one-line) way to do this. </p>

<pre><code>results = getResults()
if len(results) &gt; 0:
    result = results[0]
</code></pre>

<p>I actually don't need "results" anywhere else, and I should only run "getResults" once.</p>

<p>Any ideas?</p>
