Skip to content

Commit 8bd1f74

Browse files
committed
add example to README
1 parent 7eaf3fa commit 8bd1f74

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,3 +760,24 @@ processing at value 3
760760
processing at value 4
761761
[0, 2]
762762
```
763+
764+
# Chaining pipes
765+
766+
You can combine multiple pipes into a new one:
767+
768+
```python
769+
class ErrorDatabase:
770+
def __init__(self):
771+
self.lines = []
772+
773+
def filter_lines_by(self, predicate):
774+
filtered_lines = list(self.lines | predicate)
775+
# further processing of filtered_lines
776+
# ...
777+
return filtered_lines
778+
779+
db = ErrorDatabase()
780+
# here we combine pipes into a new one to pass it to a function call
781+
expired_reports = has_error_code | reported_by_end_customer | older_than_days(30)
782+
errors = db.filter_lines_by(expired_reports)
783+
```

0 commit comments

Comments
 (0)