break in a module

Cameron Simpson cs at zip.com.au
Fri Jun 17 22:36:42 EDT 2011


On 17Jun2011 06:00, Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
| If we were to have a "exit this module early, but without exiting Python 
| altogether" statement, I'd consider "exit" to be the most descriptive 
| name, although it would clash with existing uses of the word, e.g. 
| sys.exit(). Overloading "break" strikes me as disagreeable, but not as 
| disagreeable as overloading "return" or "in" :)

Just to throw another approach into the mix (because I was thinking
about the "finally" word), what about:

  raise StopImport

along the lines of generators' "raise StopIteration".

Then the import machinery can catch it, no new keyword is needed and no
existing keyword needs feature creeping.

Cheers,
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

And it is not our part here to take thought only for a season, or for a few
lives of Men, or for a passing age of the world.        - Gandalf the grey



More information about the Python-list mailing list