returning to the open(function import io text stream open('myfile txt'mode=' 'encoding='utf- 'print( binary io aka buffered io open('myfile dat'mode='rb'print( open('myfile dat'mode='wb'print( raw io aka unbufferedf io open('starship png'mode='rb'buffering= print( when this short example is run the output isas you can see from the outputfour different types of object have been returned from the open(function the first is textiowrapperthe second bufferedreaderthe third bufferedwriter and the final one is fileio object this reflects the differences in the parameters passed into the open ( function for examplef references io textiowrapper because it must encode (convertthe input text into unicode using the utf- encoding scheme while holds io bufferedreader because the mode indicates that we want to read binary data while holds io bufferedwriter because the mode used indicates we want to write binary data the final call to open returns fileio because we have indicated that we do not want to buffer the data and thus we can use the lowest level of stream object in general the following rules are applied to determine the type of object returned based on the modes and encoding specifiedclass mode buffering fileio bufferedreader bufferedwriter bufferedrandom textiowrapper binary 'rb'wb'rb+'wb+'ab+any text no yes yes yes yes