List comprehension is pretty good for filtering a list. Is there a good way of obtaining the other half, the filtered-out part in a single pass? For example; take this example list:
>>> a = [5, 10, 45, 99]
The following operation selects some values from that list:
>>> b = [x for x in a if somecondition(x)]
>>> b
>>> [10, 45]
But then again, I also need the other half, so I seek something like:
>>> (b, c) = divideintotwo(x, somecondition)
>>> b
>>> [10, 45]
>>> c
>>> [5, 99]
I can write this function by myself. Though, I would rather use the one that exists, if there exists. Seems a little too basic to not have one, when Python has almost everything built-in.