Pipes in Python
sulami.github.io
sulami.github.io
Then you get (from the original article)
Pype(Users.find_all) | partial(group_by_category, max=5) | print
where you have something likeclass Pype: def __init__(self, f): self.f = f
def __or__(self, f):
return type(self)(f(self.f))
You need fancier tricks to be able to make the Pipe object transparent, but its possible.The approach provided in this article is bad, it tries to reinvent a bunch of things (the operator module, for itemgetter, and stuff like getattr by wrapping them in strings.