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 -- http://mail.python.org/mailman/listinfo/python-list