Is it possible to change the newline character the .readline()
method looks for while reading lines? I might have the need to read a stream from a file object
No.
Consider creating a generator using file.read()
and yielding chunks delimited by given character.
Edit:
The sample you provided should work just fine. I would prefer to use a generator though:
def chunks(file, delim='\n'):
buf = bytearray(),
while True:
c = self.read(1)
if c == '': return
buf += c
if c == delim:
yield str(buf)
buf = bytearray()