Nice, short little book! `compose` can be simpler: def compose(fn, *fns): def _composer(f, g): return lambda *args: f(g(*args)) return reduce(_composer, fns, fn) This little function is really, really cool because it allows you to build up more interesting functions by piecing together a bunch of small, useful ones. def upper(s): return s.upper() def exclaim(s): return s + '!' # instead of this really_angry = lambda…
from pipetools import pipe, X, foreach
really_angry = pipe | upper | exclaim | exclaim
or... really_angry = X.upper() | "{0}!" | "{0}!"
(1, 2, 3, 4) > foreach((X + 1) | (X * 3)) | max
You can write some pretty neat looking concise code with this, but also may regret it later when it comes to debugging, especially when lazy evaluation is involved (which is usually the case). The stacktraces tend to be not so helpful...