You could use zip
* to combine many sequences together:
zip([a,b,c,...], [x,y,z,...]) == [(a,x), (b,y), (c,z), ...]
then you could iterate on this new sequence and make each function apply on the corresponding data. Since you just want to collect them into a list, list comprehension is much better than a for-loop:
result = [f(x) for f, x in zip(funcs, data)]
Note: * Use itertools.izip
if you are using Python 2.x and the lists are very long.)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…