[Python-ideas] for/else statements considered harmful

Guido van Rossum guido at python.org
Thu Jun 7 18:26:06 CEST 2012

On Thu, Jun 7, 2012 at 6:04 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> FWIW, I just added the following paragraph to the relevant section of
> the Python tutorial in 2.7, 3.2 and 3.3:
> =================
> When used with a loop, the ``else`` clause has more in common with the
> ``else`` clause of a :keyword:`try` statement than it does that of
> :keyword:`if` statements: a :keyword:`try` statement's ``else`` clause runs
> when no exception occurs, and a loop's ``else`` clause runs when no ``break``
> occurs. For more on the :keyword:`try` statement and exceptions, see
> :ref:`tut-handling`.
> =================

I like this. Let's not change the syntax.

--Guido van Rossum (python.org/~guido)

More information about the Python-ideas mailing list