File: class/Extras/Other/PriorClasses/scotts-sep12/actiontable.py

actions = [
    lambda x: x ** 2,
    lambda x: x ** 3,
    lambda x: x ** 4]


print actions[0](3)
print actions[1](3)

for action in actions:
    print action(4)


#-----------------------------

def f1(x): return x ** 2
def f2(x): return x ** 3
def f3(x): return x ** 4

actions = [f1, f2, f3]

print actions[0](3)
print actions[1](3)

for action in actions:
    print action(4)



[Home page] Books Code Blog Python Author Train Find ©M.Lutz