This calls the predicate once per element:
def partition(pred, iterable):
t1, t2 = tee((pred(x), x) for x in iterable)
return (x for b, x in t1 if not b), (x for b, x in t2 if b)
It's kind of inefficient though.
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/DQBFYD7KYRG6OOMXIY7IH45S25U6SXTK/
Code of Conduct: http://python.org/psf/codeofconduct/