is there a way to capture misses on a list comprehension?
<p>Based on a simple list comprehension :</p>

<pre><code>yay = [ i for i in a if a[i] ]
nay = [ i for i in a if not a[i] ]
</code></pre>

<p>I am wondering if there is a way to assign both the <code>yay</code> and <code>nay</code> values at once ( ie hits and misses on the conditional )?</p>

<p>Something that would look like this</p>

<pre><code>( yay , nay ) = ...
</code></pre>

<p>I was curious about this on readability and speed ( I was a bit surprised to see two list comprehensions are about 5% faster than a single for-loop that appends to either list )</p>

<hr>

<p>update:</p>

<p>The original example was to grab a listing of "true" and "false" valued keys in a dict...</p>

<pre><code>a = {i: i &gt;= 50 for i in range(100)}

yay = [k for k, v in a.items() if v]
nay = [k for k, v in a.items() if not v]
</code></pre>
