On Mon, 6 Jun 2022 at 16:42, Christopher Barker <[email protected]> wrote: > > I think y’all have addressed the OP’s problem — at least the performance > issues. > > But I think this brings up a pattern that I don’t have a nifty way to address: > > How do you divide a sequence into two sequences cleanly? > > The filter pattern: selectively remove items from a sequence, returning a new > sequence. There are a few ways to do that in Python. > > But what if you need both the remaining items and the removed ones? Easy > enough to write a loop that populates two lists, but is there a nifty > one-liner? > > Is this a known functional pattern? >
I'd call that a "partitioning" task, and you're right, it's not particularly easy in Python. ChrisA _______________________________________________ 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/NEY4JKQMDTMS6PN3I6VK6FCICRLCG43P/ Code of Conduct: http://python.org/psf/codeofconduct/
