Good practice of using list of function in Python

Posted by riskio on Stack Overflow See other posts from Stack Overflow or by riskio
Published on 2013-11-08T09:45:37Z Indexed on 2013/11/08 9:53 UTC
Read the original article Hit count: 169

Filed under:
|
|

I am pretty new to python and I discovered by myself that I can create a list of function and call with a for loop.

example:

def a(args):
    print "A"

def b(args):
    print "B"

def c(args):
    print "C " + str(args)


functions = [a,b,c]


for i in functions:
    i(1)

So, my question is: is there any good practice or elegant way to use list of functions and what is a good use of all this? (do have a particular name the "list of functions"?)

thank you

© Stack Overflow or respective owner

Related posts about python

Related posts about list