file reading by record separator (not line by line)
tijs_news at bluescraper.nl
Fri Jun 1 12:45:39 CEST 2007
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
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=re.compile('>|<'), end='---')
BlockReader(f, start=lambda x: x.startswith('>'))
Maybe make variations for character-based readers and line-based readers.
More information about the Python-list