Storing Functions in Dictionary [Python]
问题 I'm currently building an application where I need to iterate over a series of steps that do largely the same thing, save a very small amount of code (~15 lines). The number of steps will vary depending on how the project is configured, so it seems kind of silly for 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() { /* do step0 */ } 1: function() { /* do step1 */