Since functions are objects in python, you can actually treat * args as a list of methods and pass modeling types as args arguments at the end. This would allow you to define new simulations in the future without the need to reorganize this code.
def func(a, b, c, *args): for arg in args: arg(a, b, c) def foosim(a, b, c): print 'foosim %d' % (a + b + c) def barsim(a, b, c): print 'barsim %d' % (a * b * c)
Using:
func(2, 2, 3, foosim) func(2, 2, 3, barsim) func(2, 2, 3, foosim, barsim)
Conclusion:
foosim 7 barsim 12 foosim 7 barsim 12
source share