Skip to content

Instantly share code, notes, and snippets.

@christianscott
Last active October 25, 2017 01:23
Show Gist options
  • Save christianscott/ff100dd0581ae0eea8c3c90559eb041f to your computer and use it in GitHub Desktop.
Save christianscott/ff100dd0581ae0eea8c3c90559eb041f to your computer and use it in GitHub Desktop.
Pipe in python
def pipe(*funcs):
return lambda initial: functools.reduce(apply, funcs, initial)
def apply(arg, func):
return func(arg)
if __name__ == '__main__':
pipe(uppercase, reverse, cipher)("hello, world!") # as an example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment