multirember&co
Anton Vredegoor
anton.vredegoor at gmail.com
Fri Apr 20 13:23:29 EDT 2007
Anton Vredegoor wrote:
> def xsplitter(seq, pred):
> Q = deque(),deque()
> it = iter(seq)
> def gen(p):
> for x in it:
> Q[pred(x) == p].append(x)
> while Q[p]: yield Q[p].popleft()
> while Q[p]: yield Q[p].popleft()
> return gen(1),gen(0)
This should be:
def xsplitter(seq, pred):
Q = deque(),deque()
it = iter(seq)
def gen(p):
for x in it:
Q[pred(x)].append(x)
while Q[p]: yield Q[p].popleft()
while Q[p]: yield Q[p].popleft()
return gen(1),gen(0)
But I'm still not sure if this is the desired function. Is it normal for
people to start replying to their own messages when they're studying
coroutines?
A
More information about the Python-list
mailing list