text stream classes where buffer is the buffered binary stream encoding represents the text encoding used such as utf- errors defines the error handling policy such as strict or ignore newline controls how line endings are handled for example should they be ignored (noneor represented as linefeedcarriage return or newline/carriage return etc line_buffering if true then flush(is implied when call to write contains newline character or carriage return write_through if true then call to write is guaranteed not to be buffered the textiowrapper is wrapped around lower level binary buffered / streamfor examplef io fileio('data txt'br io bufferedreader(ftext_stream io textiowrapper(br'utf- 'stringio this is an in memory stream for text / the initial value of the buffer held by the stringio object can be provided when the instance is createdfor examplein_memory_text_stream io stringio('to be or not to be that is the question'print('in_memory_text_stream'in_memory_text_streamprint(in_memory_text_stream getvalue()in_memory_text_stream close(this generatesin_memory_text_stream to be or not to be that is the question note that the underlying buffer (represented by the string passed into the stringio instanceis discarded when the close(method is called the getvalue(method returns string containing the entire contents of the buffer if it is called after the stream was closed then an error is generated stream properties it is possible to query stream to determine what types of operations it supports this can be done using the readable()seekable(and writeable(methods for example