[Python-Dev] PEP 377 - allow __enter__() methods to skip the statement body

"Martin v. Löwis" martin at v.loewis.de
Mon Mar 16 01:37:53 CET 2009


> Well, StopIteration is still an implementation detail that only
> occasionally bleeds through to actual programming. It says nothing about
> whether using exceptions for non-exceptional circumstances (control
> flow) is good practise. Personally I think it makes the intent of code
> less easy to understand - in effect the exceptions *are* being used as a
> goto.

The same can be said about if statements and while loops - they are also
being used "as gotos". The bad thing about the goto statement is that it
allows arbitrary, unstructured control flow. This is unlike if
statements, while loops, and - yes - exceptions. They all provide for
structured control flow. raise, in particular, is no more evil than
break, continue, return, or yield.

Regards,
Martin


More information about the Python-Dev mailing list