This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author alvarezdqal
Recipients alvarezdqal
Date 2021-04-20.21:47:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1618955225.8.0.321357369426.issue43899@roundup.psfhosted.org>
In-reply-to
Content
I frequently find myself doing the following for lists, sets, and dicts.

````
passes = [x for x in seq if cond(x)]
fails = [x for x in seq if not cond(x)]
````

The proposed function would behave similarly to `filter`, but it would return a tuple of the passes iterable and fails iterable rather than just the passes.

````
my_list = [-3, -2, -1, 0, 1, 2, 3]
def is_positive(n):
    return n > 0

positives, negatives = separate(function=is_positive, iterable=my_list)
````
History
Date User Action Args
2021-04-20 21:47:05alvarezdqalsetrecipients: + alvarezdqal
2021-04-20 21:47:05alvarezdqalsetmessageid: <1618955225.8.0.321357369426.issue43899@roundup.psfhosted.org>
2021-04-20 21:47:05alvarezdqallinkissue43899 messages
2021-04-20 21:47:05alvarezdqalcreate