Guido van Rossum <[EMAIL PROTECTED]> wrote:
> Ouch. Another bug in the PEP. It was late. ;-)
>
> The "finally:" should have been "except StopIteration:" I've updated
> the PEP online.
>
> > Unless it is too early for me, I believe what you wanted is...
> >
> > itr = iter(EXPR1)
> > arg = None
> > while True:
> > VAR1 = next(itr, arg)
> > arg = None
> > BLOCK1
> > else:
> > BLOCK2
>
> No, this would just propagate the StopIteration when next() raises it.
> StopIteration is not caught implicitly except around the next() call
> made by the for-loop control code.
Still no good. On break, the else isn't executed.
How about...
itr = iter(EXPR1)
arg = None
while True:
try:
VAR1 = next(itr, arg)
except StopIteration:
BLOCK2
break
arg = None
BLOCK1
- Josiah
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com