class codecs.StreamWriter(stream, errors='strict')
Constructor for a StreamWriter
instance.
All stream writers must provide this constructor interface. They are free to add additional keyword arguments, but only the ones defined here are used by the Python codec registry.
The stream argument must be a file-like object open for writing text or binary data, as appropriate for the specific codec.
The StreamWriter
may implement different error handling schemes by providing the errors keyword argument. See Error Handlers for the standard error handlers the underlying stream codec may support.
The errors argument will be assigned to an attribute of the same name. Assigning to this attribute makes it possible to switch between different error handling strategies during the lifetime of the StreamWriter
object.
-
write(object)
-
Writes the object’s contents encoded to the stream.
-
writelines(list)
-
Writes the concatenated list of strings to the stream (possibly by reusing the
write()
method). The standard bytes-to-bytes codecs do not support this method.
-
reset()
-
Flushes and resets the codec buffers used for keeping state.
Calling this method should ensure that the data on the output is put into a clean state that allows appending of new fresh data without having to rescan the whole stream to recover state.
Please login to continue.