On Sep 29, 6:38 pm, Duncan Booth <duncan.bo...@invalid.invalid> wrote:
> Carl Banks <pavlovevide...@gmail.com> wrote:
> > Hmm, I wonder if Python should emit a warning if an else is used on a
> > for block with no break inside.  I don't think the else can be invoked
> > in any other way.  As a bonus it could catch some cases where people
> > mistakenly use it thinking it will execute when there are no
> > iterations.
>
> It will execute when there are no iterations. Did you mean to say people
> think it will execute *only* when there are no iterations?

Yes thats what I thought. for-else looks similar to if-else and in if-
else, else part is executed only when if part is not executed, but in
for-else it has entirely a different job.
Thats somewhat confusing, though it will be clear after playing around
with it.

- dksr
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to