-
Notifications
You must be signed in to change notification settings - Fork 9
Closed as not planned
Labels
part:experimentalAffects the experimental packageAffects the experimental packageresolution:wontfixThis will not be worked onThis will not be worked ontype:enhancementNew feature or enhancement visitble to usersNew feature or enhancement visitble to users
Milestone
Description
What's needed?
Receiver.filter(predicate) is very ambiguous for people not used to functional programming, as it is never clear if the receiver should receive the messages for which predicate(message) returns True or False.
Proposed solution
Add 2 new methods to Receivers:
take_while(): Alias forfilter().drop_while(): Alias forfilter(lambda m: not predicate(m))
We can also consider to deprecate filter() in the future as a way to promote more readable code.
Use cases
No response
Alternatives and workarounds
- Add a
notpredicate orfilterfalsemethod: it is more complicated and/or more work.
Additional context
The take/drop while idiom is already very widely used in many languages in conjunction with iterators/streams, like Java, Rust, Ruby and even Python itself offer those in the itertools built-in module.
Metadata
Metadata
Assignees
Labels
part:experimentalAffects the experimental packageAffects the experimental packageresolution:wontfixThis will not be worked onThis will not be worked ontype:enhancementNew feature or enhancement visitble to usersNew feature or enhancement visitble to users