file reading by record separator (not line by line)
Tijs
tijs_news at bluescraper.nl
Fri Jun 1 06:45:39 EDT 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
> 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
More information about the Python-list
mailing list