break in a module
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Fri Jun 17 02:00:41 EDT 2011
On Thu, 16 Jun 2011 22:20:50 -0700, Erik Max Francis wrote:
[...]
> Yes, which could be rephrased as the fact that `break` and `continue`
> are restricted to looping control structures, so reusing `break` in this
> context would be a bad idea. You know, kind of like the exact point I
> made earlier which you're trying to nitpick in another reply.
No offense is intended Erik, but in my experience, when people complain
about others nitpicking, they've usually said something which is *almost*
correct, i.e. wrong :)
Can we agree that the plain English verb "break", as in "to break out
of", can apply to any of:
* returning from a function
* yielding from an interator or generator
* raising an exception
* jumping via a GOTO (in languages that have GOTOs)
* exiting a loop via a break
* or any other way of exiting from a code block that I may have missed
and that only the fifth applies to the Python keyword "break"?
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" :)
--
Steven
More information about the Python-list
mailing list