sub-shell errors

Mathias Waack M.Waack at gmx.de
Fri Aug 20 16:47:53 EDT 2004


Bigbowser wrote:
> while(1):
> 
> userInput == raw_input('ICE> ')
> cmds = { 'help' : commands.displayHelp, 'version' :
> commands.displayVersion,
> 'authors' : commands.displayAuthors, 'exit' :
> commands.exitIce}
> 
> for cmd, callback in cmds:
> if userInput == cmd:
> callback()

You mean

        for cmd, callback in cmds.items()

?

Or much shorter: 

        cmds[cmd]()

Mathias



More information about the Python-list mailing list