[Tutor] Passing parameters in dictionary values?

Justin Ezequiel justin.mailinglists at gmail.com
Tue Feb 24 20:25:59 CET 2009

From: nathan virgil <sdragon1984 at gmail.com>
> selection = raw_input("Choice: ")
> choices = {"0":quit, "1":crit.talk, "2":crit.eat, "3":crit.play}
> choice = choices[selection]
> choice()
> ...so that I can call methods from a dictionary
> the problem I'm running into with this is that
> I can't pass any perimeters through the dictionary.
> What can I do?

choices = {'a': lambda: crit.eat(2), 'b': lambda: crit.eat(4), ...}
choice = choices[selection]


More information about the Tutor mailing list