codecs.StreamRecoder

class codecs.StreamRecoder(stream, encode, decode, Reader, Writer, errors='strict')[source]

StreamRecoder instances provide a frontend - backend view of encoding data.

They use the complete set of APIs returned by the codecs.lookup() function to implement their task.

Data written to the stream is first decoded into an intermediate format (which is dependent on the given codec combination) and then written to the stream using an instance of the provided Writer class.

In the other direction, data is read from the stream using a Reader instance and then return encoded data to the caller.

Methods

__enter__()
__exit__(type, value, tb)
__getattr__(name[, getattr]) Inherit all other methods from the underlying stream.
__init__(stream, encode, decode, Reader, Writer) Creates a StreamRecoder instance which implements a two-way conversion: encode and decode work on the frontend (the input to .read() and output of .write()) while Reader and Writer work on the backend (reading and writing to the stream).
__iter__()
next() Return the next decoded line from the input stream.
read([size])
readline([size])
readlines([sizehint])
reset()
write(data)
writelines(list)