[Tutor] Iterating over list of functions

spir denis.spir at free.fr
Wed May 20 18:48:17 CEST 2009


Le Wed, 20 May 2009 10:25:21 -0400,
Robert Berman <bermanrl at cfl.rr.com> s'exprima ainsi:

> What I do not know how to do is to call the selected function.

If you have options and functions "hard-coded" in lists (or if you get them from outside), you can still let python build a dict for you, using "zip":

l1 = [1,2,3]
l2 = [9,8,7]
ll = zip(l1,l2); print ll
d = dict(ll); print d
==>
[(1, 9), (2, 8), (3, 7)]
{1: 9, 2: 8, 3: 7}

Denis
------
la vita e estrany


More information about the Tutor mailing list