file write('hello stdio file\ 'file flush(fd file fileno(fd import os os write(fdb'hello descriptor file\ 'file close(create external fileobject write via file object method else os write to disk firstget descriptor from object :\temptype spam txt hello stdio file hello descriptor file lines from both schemes write via os module os open mode flags so why the extra file tools in osin shortthey give more low-level control over file processing the built-in open function is easy to usebut it may be limited by the underlying filesystem that it usesand it adds extra behavior that we do not want the os module lets scripts be more specific--for examplethe following opens descriptorbased file in read-write and binary modes by performing binary "oron two mode flags exported by osfdfile os open( ' :\temp\spam txt'(os o_rdwr os o_binary)os read(fdfile 'hello stdio file\ \nheos lseek(fdfile os read(fdfile 'hello stdio file\ \nhello descriptor file\nos lseek(fdfile os write(fdfileb'hello' go back to start of file binary mode retains "\ \noverwrite first bytes :\temptype spam txt hello stdio file hello descriptor file in this casebinary mode strings rband + in the basic open call are equivalentfile open( ' :\temp\spam txt''rb+'file read( 'hello stdio file\ \nhefile seek( file read( 'hello stdio file\ \nhello descriptor file\nfile seek( file write( 'jello' file seek( file read( 'jello stdio file\ \nhello descriptor file\nsame but with open/objects file tools