[Python-Dev] Single- vs. Multi-pass iterability

Aahz aahz@pythoncraft.com
Wed, 10 Jul 2002 20:26:36 -0400


On Tue, Jul 09, 2002, Greg Ewing wrote:
>
> Maybe a one-shot iterable should raise an exception
> if you try to obtain a second iterator from it?

Then you couldn't do this:

    done = False
    for line in f:
        if not check(line):
            break
        process(line)
    else:
        done = True

    if not done:
        for line in file:
            another_process(line)

-- 
Aahz (aahz@pythoncraft.com)           <*>         http://www.pythoncraft.com/

Project Vote Smart: http://www.vote-smart.org/