[Python-ideas] for/else syntax

geremy condra debatem1 at gmail.com
Fri Oct 2 18:07:01 CEST 2009


On Thu, Oct 1, 2009 at 11:11 PM, Yuvgoog Greenle <ubershmekel at gmail.com>wrote:

> Let me rephrase - for..else is a _misleading_ construct. It suggests one
> thing yet does another.
> This response is way too long, so here's a TOC:
> 1. The Question Challenge - A way to examine if "for..else" is just
> unintuitive or misleading.
> 2. What can be done about for...else.
> 3. Lets talk about "try/else" because a few people mentioned it as though
> it's somehow related to the discussion.
>
> ----------------
> 1. The Question Challenge - A way to examine if "for..else" is just
> unintuitive or misleading.
>
> Antti's experiment got me asking, you can try this as well. Ask a person
> who knows python the following questions:
> Question #1: Do you know what happens when an "else" appears after a "for"
> loop?
>     if they answer yes then say nevermind.
>     otherwise: continue to question #2.
> Question #2: When would the code in the "else" block execute? If you don't
> know, it's ok to guess.
>     If they answer "when a break didn't occur", I'm willing to give you,
> the asker, up to 100 lines of patch code in whatever python project you
> want..
>     If they answer "maybe when the for loop didn't run or was an empty
> list" then you don't owe me anything.
>
>
Head on over to graphine.org- I'm getting requests for database-backed
graphs and don't know enough to do it portably. I asked 4 and got 2 correct
answers, but I'm happy with the promised 100 lines. If you know as little
about databases as I do, take a look at the graphml code- it's out of date
and probably doesn't work.

Geremy Condra
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20091002/a01f2764/attachment.html>


More information about the Python-ideas mailing list