[Tutor] Re: for/else question

Andrei project5 at redrival.net
Fri Sep 12 03:41:38 EDT 2003


Gabriel Cooper wrote:
> 
> python has this weird "else" after a for loop, like so:
> 
> for x in y:
>    do stuff
> else:
>    do other stuff
> 
<snip>
> 
> So... yeah... Do /you/ use "else" with for loops? If so, when?

Ha, I didn't even know the possibility existed. Given its function, I agree that 
the word "else" is a peculiar choice, "then" or "finally" or 
"whenfinishedwithoutbreak" would be a lot better. Especially the long one, so 
people wouldn't be too tempted to use it :). I can't think of an instance where 
I'd have needed this feature.

-- 
Yours,

Andrei

=====
Mail address in header catches spam. Real contact info (decode with rot13):
cebwrpg5 at bcrenznvy.pbz. Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq gur 
yvfg, fb gurer'f ab arrq gb PP.





More information about the Tutor mailing list