[Python-Dev] GeneratorExit inheriting from Exception

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Mar 21 03:05:03 CET 2006


Aahz wrote:

> > Also maybe start issuing warnings whenever you inherit directly from
> > Exception.
> 
> -1 -- I occasionally use exceptions as a multi-loop break.  That's a
> perfectly valid Python practice, those exceptions should inherit from
> Exception, and there should not be any warnings raised.

There probably should be a ControlFlowException category
for these that would also include StopIteration and
GeneratorExit. I don't think it should include *all*
exceptions other than Errors or Warnings, though.
SystemExit and KeyboardInterrupt remain two things
that you will almost always not want to catch, even
in a top-level catch-almost-everything loop. So I'd
leave these two out on their own.

-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | Carpe post meridiam!          	  |
Christchurch, New Zealand	   | (I'm not a morning person.)          |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+


More information about the Python-Dev mailing list