Re: [Tutor] Impossible Else as Exception

2013-04-10 Thread Dave Angel
On 04/10/2013 02:18 AM, Jordan wrote: Thank you all for the feedback and suggestions. I have never used an assertion, before so I will read up on the concept. One comment about assertion. Even though an optimized run will ignore the assertion itself, it can save a (small) amount of time avo

Re: [Tutor] Impossible Else as Exception

2013-04-10 Thread Alan Gauld
On 10/04/13 07:18, Jordan wrote: Alan you are right, the code should be better tested, but test driven development seems like it would take me forever to complete even small tasks, there is so much to be tested. I have limited time to program with my wife and kids, but do you think test driven

Re: [Tutor] Impossible Else as Exception

2013-04-09 Thread Jordan
Thank you all for the feedback and suggestions. I have never used an assertion, before so I will read up on the concept. But this last email about the optimizations makes me want to go with an AssertionError exception, since assert is skipped if the compiler is told to optimize. Alan you are r

Re: [Tutor] Impossible Else as Exception

2013-04-09 Thread eryksun
On Tue, Apr 9, 2013 at 8:17 PM, Danny Yoo wrote: > > Going back to the original question: perhaps an assertion here would > be sufficient. Something like: > > assert False, "Impossible situation" Like "if __debug__" statements, assert statements are skipped by the compiler if optimization is

Re: [Tutor] Impossible Else as Exception

2013-04-09 Thread Danny Yoo
>> 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 > > > > The above isn't a great example, because the sample code *is* flawed. > The short reason why it is flawed is t

Re: [Tutor] Impossible Else as Exception

2013-04-09 Thread Steven D'Aprano
On 10/04/13 05: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

Re: [Tutor] Impossible Else as Exception

2013-04-09 Thread Alan Gauld
On 09/04/13 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, class BuggyCodeError(StandardError): pass Maybe? Seriously, exceptions are no

Re: [Tutor] Impossible Else as Exception

2013-04-09 Thread Oscar Benjamin
On 9 April 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

Re: [Tutor] Impossible Else as Exception

2013-04-09 Thread Mark Lawrence
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