[Python-3000] PEP: rename it.next() to it.next(), add a next() built-in (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Tue Mar 6 00:59:05 CET 2007
- Previous message: [Python-3000] PEP: rename it.next() to it.__next__(), add a next() built-in
- Next message: [Python-3000] PEP: rename it.next() to it.__next__(), add a next() built-in
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-3000] PEP: rename it.next() to it.__next__(), add a next() built-in
- Next message: [Python-3000] PEP: rename it.next() to it.__next__(), add a next() built-in
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]