Daniel Klein <bri...@gmail.com> writes:
> Basically I'm wondering if there are any plans to implemented named
> loops in Python, so I can tell a break command to break out of a
> specific loop in the case of nested loops. Currently I'm using boolean
> flag variables, but I find that very clumsy.

The usual way to do this in Python is with an exception, perhaps a
specially named one if that makes your code clearer:

  class Whatever(Exception): pass
  ... 
  try:
    for x in thingie:
      for y in x.whatsis():
        if lose(y): raise Whatever
        ...
  except Whatever: pass

This situation doesn't come up all that often and you should
probably ask yourself if you really need those nested loops.

You might also be able to put the nested loop structure into a
function that you can then exit with a return statement.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to