I have a list of functions names functions stored as a string which I want to nest together to create an expression applied to some input string var:
f1,f2,f3
The end result would be this string:
f1(f2(f3({var})))
How could I go about doing that? I have this which gives what I want, wondering if it can be improved?
functions = 'f1,f2,f3'
var = 'hello'
all_functions = functions.split(',')
'('.join(all_functions) + '(' + var + ')'*len(all_functions)
Result
f1(f2(f3(hello)))