How to read from a file to an arbitrary delimiter efficiently?
rosuav at gmail.com
Sat Feb 27 07:18:49 EST 2016
On Sat, Feb 27, 2016 at 11:17 PM, Chris Angelico <rosuav at gmail.com> wrote:
>> Ideally, I'd rather not over-read at all. I'd like the user to be able to
>> swap from "read N bytes" to "read to the next delimiter" (and possibly
>> even "read the next line") without losing anything.
> If those are the *only* two operations, you should be able to maintain
> your own buffer.
And, I started out by thinking "to next delimiter" and "next line"
were the same thing with different delimiters, but then went and coded
the delimiter so that wouldn't work. Whatevs. If those are the only
*three* operations, the same class with one more method could do it.
More information about the Python-list