[ Shane Hathaway ]: > I'd like to suggest a small language enhancement that would fix this > example. Allow the break and continue statements to use a keyword, > either "for" or "while", to state that the code should break out of both > the block statement and the innermost "for" or "while" statement. The > example above would change to: > > for name in filenames: > opening(name) as f: > if f.read(2) == 0xFEB0: > break for > > This could be a separate PEP if necessary. When a "break for" is used > in a block statement, it should raise a new kind of exception, > BreakForLoop, and the block statement should propagate the exception. > When used outside a block statement, "break for" can use existing Python > byte code to jump directly to the next appropriate statement.
What about nested blocks ? When they act as iterators that would be desireable too. What to do then: - baptize blocks -> break <name> - keep them anonymous -> break #enclosing_scope_counter - do not support them cheers, Senra -- Rodrigo Senra -- MSc Computer Engineer rodsenra(at)gpr.com.br GPr Sistemas Ltda http://www.gpr.com.br/ Personal Blog http://rodsenra.blogspot.com/ _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com