I am trying to do the usual thing of asking for an input and then checking it to see if it is valid. If the entry is not valid then ask again until you get the correct answer.
I have come up with this class. I am trying to make a transition from procedural programming to object oriented. Is this a good approach for such a check? It seems to me this is more work then needed. (I can put in a counter also to break out if you try too many times). Please comment if you have the time. class greating: def __init__(self): self.OK = False self.lowValue = 1 self.highValue = 6 def opening(self): print """ Please choose from the following options. 1) - Normal Unit test with static data. 2) - Normal Unit test with missing data. 3) - Integration test with current DTG. 4) - Integration test with missing data. 5) - Clean directory 6) - Exit """ self.choice = raw_input("Choice(1-6) ") def check(self): try: self.choice = int(self.choice) except ValueError: print "Please enter a number from ",self.lowValue," to ",self.highValue pass if self.choice > self.highValue or self.choice < self.lowValue: print "You have entered an invalid entry. Please try again" else: self.OK = True a = greating() while a.OK != True: a.opening() a.check() print a.choice _______________________________________________ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor