On this page
io.RawIOBase
Prev: io.open_code | Up: io | Next: io.Reader
Rel: io.BlockingIOError, io.BufferedIOBase, io.BufferedRandom, io.BufferedReader
Ref: docs.python.org — io.RawIOBase
Tags: #public #python3 #stdlib #io
Import
import io
from io import RawIOBase
Signature & Overview
io.RawIOBase()
Base class for raw binary I/O.
Methods & Attributes
RawIOBase.close(self, /)— Flush and close the IO object.RawIOBase.fileno(self, /)— Return underlying file descriptor if one exists.RawIOBase.flush(self, /)— Flush write buffers, if applicable.RawIOBase.isatty(self, /)— Return whether this is an 'interactive' stream.RawIOBase.read(self, size=-1, /)—RawIOBase.readmethod/property.RawIOBase.readable(self, /)— Return whether object was opened for reading.RawIOBase.readall(self, /)— Read until EOF, using multiple read() call.RawIOBase.readinto(...)—RawIOBase.readintomethod/property.RawIOBase.readline(self, size=-1, /)— Read and return a line from the stream.RawIOBase.readlines(self, hint=-1, /)— Return a list of lines from the stream.RawIOBase.seek(self, offset, whence=0, /)— Change the stream position to the given byte offset.RawIOBase.seekable(self, /)— Return whether object supports random access.RawIOBase.tell(self, /)— Return current stream position.RawIOBase.truncate(self, size=None, /)— Truncate file to size bytes.RawIOBase.writable(self, /)— Return whether object was opened for writing.RawIOBase.write(...)—RawIOBase.writemethod/property.RawIOBase.writelines(self, lines, /)— Write a list of lines to stream.
Usage
import io
# Base class for unbuffered binary streams like io.FileIO
assert issubclass(io.FileIO, io.RawIOBase)
Gotchas
- Short reads/writes are normal: Subclasses implement
readinto()andwrite()at the OS syscall level; wrap inBufferedReader/BufferedWriterfor normal application code.
REPL Inspect
from io import RawIOBase
help(RawIOBase)
Linked from
Related notes
- tuts/python3/stdlib_module/io/open_code Linked here; links to this page; shared tags: #io, #stdlib
- tuts/python3/stdlib_module/io/Reader Linked here; links to this page; shared tags: #io, #stdlib
- tuts/python3/stdlib_module/io Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/io/BlockingIOError Linked here; shared tags: #io, #stdlib
- tuts/python3/stdlib_module/io/BufferedIOBase Linked here; shared tags: #io, #stdlib
- tuts/python3/stdlib_module/io/BufferedRandom Linked here; shared tags: #io, #stdlib
- tuts/python3/stdlib_module/io/BufferedReader Linked here; shared tags: #io, #stdlib
- tuts/c/stdlib/stdio_and_file_io shared tags: #io, #stdlib
- tuts/cpp/stdlib/io_and_filesystem shared tags: #io, #stdlib
- tuts/cpp/stdlib/io_and_filesystem/format_and_print shared tags: #io, #stdlib