Record separator for readlines()

jepler at jepler at
Sat Sep 3 05:10:18 CEST 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 =
		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
	    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: <>

More information about the Python-list mailing list