Record separator for readlines()
jepler at unpythonic.net
jepler at unpythonic.net
Fri Sep 2 23:10:18 EDT 2005
I think you still have to roll your own.
Here's a start:
def ireadlines(f, s='\n', bs=4096):
if not s: raise ValueError, "separator must not be empty"
r = []
while 1:
b = f.read(bs)
if not b: break
ofs = 0
while 1:
next = b.find(s, ofs)
if next == -1: break
next += len(s)
yield ''.join(r) + b[ofs:next]
del r[:]
ofs = next
r.append(b[ofs:])
yield ''.join(r)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050902/c449a923/attachment.sig>
More information about the Python-list
mailing list