On Fri, Oct 16, 2009 at 7:25 AM, Robert Johansson <[email protected]> wrote:
> What if a valid user input has to be an integer between 10 and 20? I mean, > it could be that you are doing something that only makes sense for that > input. Would it be pythonic to add a test like: > > If prompt in range(10,21): Better to write if 10 <= prompt <= 20: > ... > else: > ... raise an error > > If I understand the error handling correctly you can add your own user > defined error, but is that really what you should do in that case? It depend on the context. You could raise ValueError (it's OK to raise built-in exception types if they apply) or your own exception type or just handle the error. Kent _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
