Here's a quick dumb example, hope it helps:<br><br>def function1(a,b,c):<br> print a,b,c<br>def function2(x):<br> print x<br>def function3(y):<br> print y+3<br><br>def executeall(list):<br> print "setting up"<br>
for function,args in list:<br> function(*args) #Calls the function passing in the arguments<br><br>mylist = [[function1,(1,2,3)],[function2,("green",)],[function3,(5.5,)]]<br>executeall(mylist)<br><br>
---------<br>The hard part is the fact that you mentioned some arguments need to be passed in, some of the time. This kind of situation makes the most sense if all of the functions take the same arguments (or no arguments). Then you could just do this:<br>
--------------------<br>def function1():<br>
print 1<br>
def function2():<br>
print 2<br>
def function3():<br>
print 3<br>
<br>
def executeall(list):<br>
print "setting up"<br>
for function in list:<br>
function()<br>
<br>
mylist = [function1,function2,function3]<br>executeall(mylist)<br>--------------------------<br>So you see, treating functions as regular objects and passing them around, is as easy as not putting the call operator (parenthesis) to the right of the function name.<br>
<br>print function #Prints the representation of the function object<br>print function() #Calls the function and then prints what the function returns<br><br>Hope it helps.<br>