Pythonic function composition

Alan G Isaac aisaac at american.edu
Mon Oct 25 16:29:24 CEST 2004


Given a list of functions, it seems there must be a
Pythonic approach to composition.  Something like

def compose(fns): return lambda x: reduce(lambda f,g: f(g),fns)(x)

This will not work because the argument 'x' is not "inside".
What is the proper formulation?

Thanks,
Alan Isaac





More information about the Python-list mailing list