Skip to content

Commit

Permalink
add example to README
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuhn, Eugen (uidr5438) authored and Kuhn, Eugen (uidr5438) committed May 4, 2023
1 parent 7eaf3fa commit b096bec
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -760,3 +760,24 @@ processing at value 3
processing at value 4
[0, 2]
```

# Chaining pipes

You can combine multiple pipes into a new one:

```python
class ErrorDatabase:
def __init__(self):
self.lines = []

def filter_lines_by(self, predicate):
filtered_lines = list(self.lines | predicate)
# further processing of filtered_lines
# ...
return filtered_lines

db = ErrorDatabase()
# here we combine pipes into a new one to pass it to a function call
expired_reports = has_error_code | reported_by_end_customer | older_than_days(30)
errors = db.filter_lines_by(expired_reports)
```

0 comments on commit b096bec

Please sign in to comment.