Function composition in Python

The pointfree module is about using function composition notation in conjunction with automatic partial application. Both of these features are achieved by wrapping functions in the pointfree class (which can also be applied as a decorator).

Several “pre-wrapped” helper functions are provided by the module. For instance, if you wanted to define a function that returns the sum of squares of the lengths of the strings in a list, you could do so by combining the helpers pfmap() and pfreduce():

>>> from pointfree import *
>>> from operator import add

>>> fn = pfmap(len) >> pfmap(lambda n: n**2) >> pfreduce(add, initial=0)
>>> fn(["foo", "barr", "bazzz"])
50

Interesting module. I've been looking for something like this in order to build a stream-like composition of functions to process huge datasets, and maybe I could use this.