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 -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/DQBFYD7KYRG6OOMXIY7IH45S25U6SXTK/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to