Working around a lack of 'goto' in python

Roger Binns rogerb at rogerbinns.com
Mon Mar 8 22:14:05 CET 2004


> Look, a bug!
>
> With this "feature", you have to scan the entire body of the loop
> looking for a numeric break/continue if you're going to change the
> indentation level, then increment or decrement the number.

Yes, but you can screw up any code when adding loops.

Original:

  while some condition:
      do work
      if condition1:
           continue
      if other condition:
           break
      do work

Add a loop:

  while some condition:
      do work
      for item in stuff:
          if condition1:
               continue
          if other condition:
               break
      do work

Look, a bug!  (The continue and break should be jumping two levels).

Roger





More information about the Python-list mailing list