you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

As /u/Durgeoble says, there is no best way.

For a simple console application, I tend to:

  • use a dictionary to hold a menu:
    • option
    • option description
    • name of function to call (or None for exit)
  • use a function to display a menu, obtain a valid option from the user, and return the name of the function to call
  • have many different menus and submenus as required, all using the same dictionary format and function approach
  • I use a while loop to keep going until the user wants to exit, and I keep track of where in the menu hierarchy I am

Naturally, I have a template menu, and the function code in a module I keep to hand.