def f2(arg):
    return "f2 "+arg

def f1(arg):
    return "f1 "+arg

a={"1":"f1","2":"f2"}
print [eval(x[1])(x[0]) for x in a.items()]
def f2(arg):
    return "New f2 "+arg
print [eval(x[1])(x[0]) for x in a.items()]

Neat trick, if probably dangerous in some circumstances. Anyway, thanks, I didn't think of that.

Don't know if this is any use to you..

At least I learned something. :-)




--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to