Message391479
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)
```` |
|
Date |
User |
Action |
Args |
2021-04-20 21:47:05 | alvarezdqal | set | recipients:
+ alvarezdqal |
2021-04-20 21:47:05 | alvarezdqal | set | messageid: <1618955225.8.0.321357369426.issue43899@roundup.psfhosted.org> |
2021-04-20 21:47:05 | alvarezdqal | link | issue43899 messages |
2021-04-20 21:47:05 | alvarezdqal | create | |
|