[Python-ideas] for/else syntax

Yuvgoog Greenle ubershmekel at gmail.com
Sat Oct 3 18:27:45 CEST 2009

On Sat, Oct 3, 2009 at 7:19 PM, Ron Adam <rrr at ronadam.com> wrote:
> True, and that is part of the other 20% I expect the documentation would't
> help.
> The only solution to that that I can think of is to change the esle's in for
> and while loops to for/then and while/then in Python 5.0.
> It might be doable, and if enough people want it, then just maybe...

Documenting this syntax with the appropriate warnings and clear
explanations is very important.

But I don't think the amount of code mishaps on this thread are
properly addressed just by better documentation. The syntax I proposed
is harmless, it won't break any existing code, and it's something
people in python 3 can use right now. Deprecation etc can wait for
python 4. Don't tea5e me :)

Of course people here would have to say if my idea sounds good or not.

while still_more_items():
    if found_it():
if not break:
    # exhausted search space

More information about the Python-ideas mailing list