class io.RawIOBase
Base class for raw binary I/O. It inherits IOBase
. There is no public constructor.
Raw binary I/O typically provides low-level access to an underlying OS device or API, and does not try to encapsulate it in high-level primitives (this is left to Buffered I/O and Text I/O, described later in this page).
In addition to the attributes and methods from IOBase
, RawIOBase
provides the following methods:
-
read(size=-1)
-
Read up to size bytes from the object and return them. As a convenience, if size is unspecified or -1,
readall()
is called. Otherwise, only one system call is ever made. Fewer than size bytes may be returned if the operating system call returns fewer than size bytes.If 0 bytes are returned, and size was not 0, this indicates end of file. If the object is in non-blocking mode and no bytes are available,
None
is returned.
-
readall()
-
Read and return all the bytes from the stream until EOF, using multiple calls to the stream if necessary.
-
readinto(b)
-
Read bytes into a pre-allocated, writable bytes-like object b, and return the number of bytes read. If the object is in non-blocking mode and no bytes are available,
None
is returned.
-
write(b)
-
Write the given bytes-like object, b, to the underlying raw stream, and return the number of bytes written. This can be less than the length of b in bytes, depending on specifics of the underlying raw stream, and especially if it is in non-blocking mode.
None
is returned if the raw stream is set not to block and no single byte could be readily written to it. The caller may release or mutate b after this method returns, so the implementation should only access b during the method call.
Please login to continue.