On Fri, Oct 16, 2009 at 9:44 AM, Robert Johansson <[email protected]> wrote: > If I wanted prompt to be an integer, is my check with range still bad?
If the prompt is coming from raw_input() then you have already guaranteed it is an integer when you convert it in a try/except block. > Is this the way to define my own error and to use it: > > class MyValueError(Exception): > define initialization and printing You usually don't need to define anything extra, the Exception methods are fine. > try: > if test ok: > ... > else: > raise MyValueError raise MyValueError() # with parentheses to create an instance > except MyValueError: Kent _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
