On Sat, 29 Dec 2007 15:10:24 -0800, Raymond Hettinger wrote:

> These thoughts reflect my own experience with the itertools module.
> It may be that your experience with them has been different.  Please
> let me know what you think.

I seem to be in a minority here as I use both functions from time to time.
One "recipe" is extracting blocks from text files that are delimited by a
special start and end line.

def iter_block(lines, start_marker, end_marker):
    return takewhile(lambda x: not x.startswith(end_marker),
                     dropwhile(lambda x: not x.startswith(start_marker),
                               lines))

Maybe these functions usually don't turn up in code that can be called
"recipes" so often but are useful for themselves.

Ciao,
        Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to