On Fri, 13 Apr 2001, Ron Stephens wrote: > So, now I consider procedural menu program using raw_input. Still, > how do I go to the appropriate sub-program when the user chooses > one? With goto's this would be trivial. Even more trivial without them. import sys def a(): print "processing using algorithm A" def b(): print "processing using algorithm B" def c(): print "processing using algorithm C" def quit(): sys.exit(0) cmds = { "A": a, "B": b, "C": c, "exit": quit } while 1: cmd = raw_input("> ") if cmd not in cmds.keys(): print "unknown command %s" % cmd else: cmds[cmd]() -- Bob Kline mailto:bkline at rksystems.com http://www.rksystems.com
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4