Best method for a menu in a command line program?
Ben Finney
ben+python at benfinney.id.au
Thu Nov 4 07:33:00 EDT 2010
Arnaud Delobelle <arnodel at gmail.com> writes:
> Ben Finney <ben+python at benfinney.id.au> writes:
> [...]
> > commands = {
> > 'q': (lambda: quit()),
> > 'c': (lambda: prompt_and_convert_temperature(
> > ["Celsius", "Fahrenheit"], celsius_to_fahrenheit)),
> > 'f': (lambda: prompt_and_convert_temperature(
> > ["Fahrenheit", "Celsius"], fahrenheit_to_celsius)),
>
> None: print_commands,
This would be counter to the problem as stated by the OP. The program
originally described loops *only* if no other command is specified;
yours doesn't distinguish.
--
\ “It is far better to grasp the universe as it really is than to |
`\ persist in delusion, however satisfying and reassuring.” —Carl |
_o__) Sagan |
Ben Finney
More information about the Python-list
mailing list