split list by condition in python
<p>by now i didn't find a convenient way to split a list by certain conditions ,for example,i have a record list:</p>

<pre><code> a = ((0,1),(1,0),(0,2),(1,0),(3,0),(4,0),(0,3),(1,5)....)
</code></pre>

<p>i want to split the content into 2 lists</p>

<pre><code>alist = []
blist = []
for x in a:
    if x[0] == 0:
        alist.append(x)
    elif x[0] == 1:
        blist.append(x)
</code></pre>

<p>not very concise</p>

<p>write in list comprehensions</p>

<pre><code>aList = [x for x in a if x[0] == 0]
bList = [x for x in a if x[0] == 1]
</code></pre>

<p>list comprehensions are usually good for reading and performance,but in this case the list must be iterate in two times.</p>

<p>is there a better way to do this job?</p>
