On 6/10/07, Stef Mientki <[EMAIL PROTECTED]> wrote: > I can realize it with a simple switch within each function, > but that makes the code much less readable: > > def Some_Function(): > if simulation_level == 1: > ... do things in a way > elif simulation_level == 2: > ... do things in another way > elif simulation_level == 3: > ... do things in yet another way
If you only have three levels, then that definitely is the best way to solve the problem. If you have more, and if they may change, then use a dispatch-dict: def simulator_1(): print 'mooo' ... simulators = {1 : simulartor_1, 2 : simulator_2, 3 : simulator_3} def Some_Function(): simulators[simulation_level]() -- mvh Björn -- http://mail.python.org/mailman/listinfo/python-list