Better way to call a chain of functions in python?

python

Solution

Use a loop:

out = initial_input
for func in [function1, function2, function3, function4]:
    out = func(out)

Problem

I have a chain of operations which needs to occur one after the other and each depends on the previous function's output. Like this: ``` out1 = function1(initial_input) out2 = function2(out1) out3 = function3(out2) out4 = function4(out3) ``` and so on about 10 times. It looks a little ugly in the code. What is the best way to write it? Is there someway to handle it using some functional programming magic? Is there a better way to call and execute this function chain?

Original source

Related problems