A function that calls X function

后端 未结 4 402
借酒劲吻你
借酒劲吻你 2021-01-17 05:41

I want to basically turn a list element into a function with the do function. This way any pre-written funcction i can call by just use a do(list[x]).

What im tryin

4条回答
  •  余生分开走
    2021-01-17 06:33

    You don't need the extra functions, and you don't need to turn them into a string either:

    def func():
        print "python"
    
    def func1():
         print "is"
    
    def func2():
         print "awesome"
    
    funcs = [func, func1, func2]
    
    for function in funcs:
        function()
    

提交回复
热议问题