New submission from David Alvarez Lombardi <alvarezd...@gmail.com>:
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) ```` ---------- messages: 391479 nosy: alvarezdqal priority: normal severity: normal status: open title: separate builtin function type: enhancement versions: Python 3.10 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43899> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com