Python2 Function Pointers

2016-02-09
#! /usr/bin/env python2


def toto(arg):
    print "func toto => " + str(arg)

def tutu(arg):
    print "func tutu => " + str(arg)

def tata(arg):
    print "func tata => " + str(arg)

def titi(arg):
    print "func titi => " + str(arg)

functDict = {'toto': toto,
             'tutu': tutu,
             'tata': tata,
             'titi': titi}

counter = 0
for item in functDict:
    functDict[item](counter)
    counter += 1

Will output:

func tutu => 0  
func titi => 1  
func toto => 2  
func tata => 3