The type of file object returned by the open() function
depends on the mode. When open() is used to open a file in a text
mode ('w' , 'r' , 'wt' , 'rt' , etc.), it returns a subclass of
io.TextIOBase (specifically io.TextIOWrapper ). When used
to open a file in a binary mode with buffering, the returned class is a
subclass of io.BufferedIOBase . The exact class varies: in read
binary mode, it returns an io.BufferedReader ; in write binary and
append binary modes, it returns an io.BufferedWriter , and in
read/write mode, it returns an io.BufferedRandom . When buffering is
disabled, the raw stream, a subclass of io.RawIOBase ,
io.FileIO , is returned.
|