[Python-ideas] for/else syntax

Georg Brandl g.brandl at gmx.net
Sat Oct 3 19:07:13 CEST 2009


Gerald Britton schrieb:
> Yes, quite right.  Another way would be:
> 
> for i, j in enumerate(x):
>   # do something
>   i += 1
> else:
>  if "i" not in vars():
>    i = 0

And there is STILL no need for using an else clause here.

Georg

-- 
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.




More information about the Python-ideas mailing list