Josiah Carlson wrote:
> It's already spelled...
>
> for item in iter:
> #code for when we got something
> break
> else:
> #code for when we didn't get anything
Technically this is true, but I can't help feeling
that's a terribly obscure way to use a for-loop.
Normally 'for' means you're iterating over the
whole sequence, or at least potentially more than
one item from it. A different keyword at the
beginning would make it much clearer that you
only want one item.
BTW, I would really have liked to make it
with item from iter:
...
else:
...
but I fear that would be impossibly confusing
given what we've already used 'with' for. :-(
--
Greg
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com