all Python 3ioterm
io.RawIOBase
abstract bases
The abstract base class for raw (unbuffered) binary streams; FileIO is its implementation.
Syntax
issubclass(cls, io.RawIOBase)
You rarely hold a raw stream directly: open(path, 'rb', buffering=0) returns one, and an ordinary buffered file exposes it through its .raw attribute. Every read()/write() maps to a separate system call, and read(n) may return fewer than n bytes even before EOF, so you must loop to read the rest yourself — normal code sticks to the buffered layer and drops to raw only when it needs full control over I/O.
Examples
import io
print(issubclass(io.FileIO, io.RawIOBase)) # → True
print(issubclass(io.RawIOBase, io.IOBase)) # → True
print(issubclass(io.BufferedReader, io.RawIOBase)) # → False
print(isinstance(io.BytesIO(), io.RawIOBase)) # → False
print(hasattr(io.RawIOBase, 'readinto')) # → True
See also
Open in the full glossarydocs.python.orgReport an inaccuracy