I picked up python again, and I am proud with what I have without using if/elif statements throughout the whole thing. I have modified this couple of times, since I kept asking how could I make it better or more organized. My biggest complaint is using the if/elif at the bottom, for some reason when I use.
func = optionMenu.get(test, "INVALID ENTRY")
it would would return blank instead of showing "invalid entry" if I selected option that wasn't on the menu. So, I had to use if/else to band-aid it for now.
#!/usr/bin/env python
import os
def mainMenu():
print "=" * 25
print "Please Select An Option"
print "=" * 25
print ""
print "1. option one\n"
print "2. option two\n"
print "3. option three\n"
print "4. filler\n"
menuOption = input("Select Option: ")
optionSelect(menuOption)
class selections(object):
def one(self):
print "option one"
def two(self):
print "option two"
def three(self):
print "option three"
def four(self):
print "option four"
def optionSelect(test):
menuSelection = selections()
optionMenu = {
1 : menuSelection.one,
2 : menuSelection.two,
3 : menuSelection.three,
4 : menuSelection.four,
}
func = optionMenu.get(test)
if test in optionMenu:
func()
else:
print "ERROR INVALID ENTRY ERROR"
mainMenu()