[Tutor] Impossible Else as Exception
Mark Lawrence
breamoreboy at yahoo.co.uk
Tue Apr 9 22:38:45 CEST 2013
On 09/04/2013 20:22, Jordan 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
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
The RuntimeError builtin see
http://docs.python.org/3/library/exceptions.html#RuntimeError.
--
If you're using GoogleCrap™ please read this
http://wiki.python.org/moin/GoogleGroupsPython.
Mark Lawrence
More information about the Tutor
mailing list