On 9 April 2013 20:22, Jordan <wolfrage8...@gmail.com> wrote: > I want to know what exception should be raised if there is a bug in my code > that allows an else statement to be triggered, because the else condition in > my code should be impossible, unless there is an error in my code. What > exception should I raise so that if my code is wrong it will raise an > exception which will give me a trace back? Which would be most Pythonic? > > Example: > > if condition is 1: > do something with 1 > elif condition is 2: > do something with 2 > else: # Impossible unless the code above is flawed. > Raise Exception
AssertionError is raised when an assert statement fails. Since this situation is essentially an implicit assert it would make sense to use that. Oscar _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor