[Python-ideas] for/except/else syntax
Guido van Rossum
guido at python.org
Thu Oct 8 18:27:09 CEST 2009
On Thu, Oct 8, 2009 at 7:07 AM, George Sakkis <george.sakkis at gmail.com> wrote:
> The more people disagree on how "for/else" should be spelled,
> the more I think there is no keyword that can encapsulate what it does
> unambiguously. Certainly "then" leaves me as clueless as "else" for
> the reasons above. I was thinking of something verbose like
> "elifnotbreak", but not only it is ugly, it is not 100% accurate; the
> correct spelling would be "elifnotbreakandnotreturnandnotexception" ;)
It is something that has to be learned. Now, lots of things have to be
learned -- the behavior of range(1, 10) does not come naturally to
many people either. But apparently for-else is used rarely enough
that, given the way most people learn (by trying and by reading
others' code, not by reading docs), many people don't know about it.
That's a flaw, and I don't quite know what to do about it. It's about
20 years too late to remove or rename it. But we probably should not
do more of these. That's a lesson.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-ideas
mailing list