stream io in the above figure the initial fileio stream reads raw data from the actual data source (in this case filethe bufferedreader then buffers the data reading process for efficiency finally the textiowrapper handles string encodingthat is it converts strings from the typical ascii representation used in file into the internal representation used by python (which uses unicodeyou might ask at this point why have streams model at allafter all we read and wrote data to files without needing to know about streams in the last the answer is that stream can read or write data to or from source of data rather than just from file of course file can be source of data but so can socketa pipea stringa web service etc it is therefore more flexible data / model python streams the python io module provides python' main facilities for dealing with data input and output there are three main types of input/output these are text /obinary / and raw io these categories can be used with various types of data source/sinks whatever the categoryeach concrete stream can have number of properties such as being read-onlywrite-only or read-write it can also support sequential access or random access depending on the nature of the underlying data sink for examplereading data from socket or pipe is inherently sequential where as reading data from file can be performed sequentially or via random access approach whichever stream is used howeverthey are aware of the type of data they can process for exampleattempting to supply string to binary write-only stream will raise typeerror as indeed will presenting binary data to text stream etc as suggested by this there are number of different types of stream provided by the python io module and some of these are presented below