I am currently creating an application in which I need to iterate through a series of steps that do basically the same thing, except for a very small amount of code (~ 15 lines). The number of steps will vary depending on how the project is configured, so it seems silly to me to create a separate function for each potential instance.
In JavaScript, I would do something like this:
var switches = [true, true, false, true]; var holder = { 0: function() { } 1: function() { } 2: function() { } 3: function() { }
Is there a way to do something like this in python? The only thing I can think of is something like this:
switches = [True, True, False, True] class Holder(object): @staticmethod def do_0():
It seems terribly inefficient if I have a significant number of steps. Is there a better way to do this?
javascript python dictionary arrays data-structures
Robert Ingrum
source share