[Python-ideas] Nudging beginners towards a more accurate mental model for loop else clauses

Nick Coghlan ncoghlan at gmail.com
Fri Jun 8 14:12:47 CEST 2012

On Fri, Jun 8, 2012 at 10:05 PM, Rob Cliffe <rob.cliffe at btinternet.com> wrote:
> Fair enough, but I think my more compact versions are more readable.

At the expense of adding 3 new keywords to the language for something
that can already be handled with ordinary variable assignments. They
would add no real expressive power to the language, so they just
become another special case for newcomers to learn. Not a good

With the benefit of hindsight, we can also see that supporting the
"else" clause on loops wasn't a good trade-off either (given the
confusion it can cause). However, since the mistake has already been
made, a lot of code out in the wild relies on it and those of us that
quite like the construct are used to having it available, it's not
worth the hassle of deprecating and removing it.


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list