| Store | Cart

Working around a lack of 'goto' in python

From: gabor <gab...@z10n.net>
Wed, 10 Mar 2004 17:34:03 +0100
On Tue, 2004-03-09 at 22:05, Roy Smith wrote:
> Joe Mason <joe at notcharles.ca> wrote:> > > In article <roy-F325DF.12255009032004 at reader2.panix.com>, Roy Smith wrote:> > > OK, I'll bite.  What's wrong with exceptions for breaking out of deeply > > > nested loops?> > > > Philosophically, the termination condition of a loop isn't an> > exceptional circumstance.> > The normal flow of control is when you fall out the bottom of the loop > when your control test goes false.  Breaking out of the middle is indeed > an exceptional circumstance; it is an exception to the normal flow of > control.  People tend to think of exceptions as errors, but they don't > have to be.> > Now, to be fair, imagine a construct like this:> > try:>   for i in range (iMax):>      for j in range (jMax):>        for k in range (kMax):>           if thisIsIt (i, j, k):>              raise IFoundIt>    print "it's not there"> except IFoundIt:>    print "yes it is"> > Presumably the expectation is that the thing you're looking for will > exist somewhere in the i,j,k coordinate space.  Falling out the bottom > of the loop is now the error condition.  I think this is what you were > getting at, and I agree that this turns the whole concept of an > exception on its ear.

i think the biggest problem with this exception-stuff is the naming.

the name 'exception' immediately means (for me at least) some kind of
error condition.... 

maybe if they had a different name, it would be easier to use them also
by non-error-conditions.

gabor

Recent Messages in this Thread
Brett Mar 06, 2004 06:18 pm
Andrew Koenig Mar 06, 2004 06:30 pm
Carmine Noviello Mar 06, 2004 06:41 pm
Jeff Schwaber Mar 06, 2004 06:41 pm
Peter Otten Mar 06, 2004 06:48 pm
Rene Pijlman Mar 06, 2004 06:49 pm
Christian Tismer Mar 06, 2004 08:50 pm
Roy Smith Mar 06, 2004 09:16 pm
Stephen Horne Mar 08, 2004 05:01 am
Dan Bishop Mar 06, 2004 11:23 pm
David M. Cooke Mar 07, 2004 08:49 am
Stephen Horne Mar 07, 2004 06:35 pm
Roy Smith Mar 07, 2004 06:54 pm
Stephen Horne Mar 07, 2004 07:57 pm
Roy Smith Mar 07, 2004 08:49 pm
Stephen Horne Mar 08, 2004 02:54 am
benjamin schollnick Mar 08, 2004 03:38 am
Stephen Horne Mar 08, 2004 05:10 am
Roger Binns Mar 07, 2004 10:33 pm
Roy Smith Mar 08, 2004 02:11 am
Roger Binns Mar 08, 2004 05:09 am
Georgy Mar 08, 2004 09:09 am
Jeff Epler Mar 08, 2004 02:50 pm
Mel Wilson Mar 08, 2004 03:43 pm
Roger Binns Mar 08, 2004 08:43 pm
Donn Cave Mar 08, 2004 10:46 pm
Roger Binns Mar 09, 2004 12:11 am
Stephen Horne Mar 08, 2004 03:30 am
Stephen Horne Mar 08, 2004 05:29 am
Y2KYZFR1 Mar 08, 2004 04:41 pm
Lou Pecora Mar 08, 2004 04:59 pm
Y2KYZFR1 Mar 09, 2004 04:36 pm
Joe Mason Mar 09, 2004 04:57 pm
Roy Smith Mar 09, 2004 05:25 pm
Joe Mason Mar 09, 2004 06:53 pm
Roy Smith Mar 09, 2004 09:05 pm
Roger Binns Mar 10, 2004 04:23 am
Roy Smith Mar 10, 2004 01:52 pm
Isaac To Mar 10, 2004 05:36 am
Jeff Epler Mar 10, 2004 01:05 pm
Isaac To Mar 10, 2004 03:58 pm
gabor Mar 10, 2004 04:34 pm
Donn Cave Mar 10, 2004 05:49 pm
Stephen Horne Mar 11, 2004 03:02 am
Jacek Generowicz Mar 11, 2004 11:40 am
Stephen Horne Mar 11, 2004 02:50 pm
Stephen Horne Mar 09, 2004 09:43 pm
Roy Smith Mar 09, 2004 09:55 pm
Stephen Horne Mar 10, 2004 12:41 am
Isaac To Mar 10, 2004 05:16 am
Christopher A. Craig Mar 08, 2004 07:54 pm
leeg Mar 09, 2004 01:34 am
Stephen Horne Mar 09, 2004 09:52 pm
leeg Mar 10, 2004 02:46 pm
Stephen Horne Mar 10, 2004 04:58 pm
Roger Binns Mar 10, 2004 06:14 pm
David MacQuigg Mar 09, 2004 11:26 pm
Anton Vredegoor Mar 10, 2004 10:11 am
Messages in this thread