Skip to content

Instantly share code, notes, and snippets.

@kamikat
Last active March 18, 2021 19:02
Show Gist options
  • Save kamikat/5607645 to your computer and use it in GitHub Desktop.
Save kamikat/5607645 to your computer and use it in GitHub Desktop.
a simple demo of pipeline pattern for python
def processor1(obj):
"""Require: text; yield firstchar"""
obj['firstchar'] = obj.text[:1]
return obj
def processor2(obj):
"""Require: firstchar, text2; yield concat"""
obj['concat'] = obj.firstchar + obj.text2
return obj
procs = [
processor1,
processor2
]
obj = {
text: "Kr",
text2: " 233..."
}
for proc in procs:
proc(obj)
print obj
@pestefo
Copy link

pestefo commented Aug 9, 2020

But... in the Pipeline Pattern the input of one process is the output of another. Am I wrong?

Btw, thanks for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment