Steve Howell wrote: >> >> from blockread import BlockReader >> >> b = BlockReader(f, boundary='>') >> for block in b: >> # whatever >> > > Yep, I like this idea. You might have a few > variations: >
Yes, or a single one that takes a wide range of construction possibilities, like strings, lambdas or regexes in various keyword parameters. BlockReader(f, start='>') BlockReader(f, start=re.compile('>|<'), end='---') BlockReader(f, start=lambda x: x.startswith('>')) Maybe make variations for character-based readers and line-based readers. -- Regards, Tijs -- http://mail.python.org/mailman/listinfo/python-list