On this page
io.BufferedRWPair
Prev: io.BufferedReader | Up: io | Next: io.BufferedWriter
Rel: io.BlockingIOError, io.BufferedIOBase, io.BufferedRandom, io.BufferedReader
Ref: docs.python.org — io.BufferedRWPair
Tags: #public #python3 #stdlib #io
Import
import io
from io import BufferedRWPair
Signature & Overview
io.BufferedRWPair(reader, writer, buffer_size=131072, /)
A buffered reader and writer object together.
Methods & Attributes
BufferedRWPair.close(self, /)—BufferedRWPair.closemethod/property.BufferedRWPair.detach(self, /)— Disconnect this buffer from its underlying raw stream and return it.BufferedRWPair.fileno(self, /)— Return underlying file descriptor if one exists.BufferedRWPair.flush(self, /)—BufferedRWPair.flushmethod/property.BufferedRWPair.isatty(self, /)—BufferedRWPair.isattymethod/property.BufferedRWPair.peek(...)—BufferedRWPair.peekmethod/property.BufferedRWPair.read(...)—BufferedRWPair.readmethod/property.BufferedRWPair.read1(...)—BufferedRWPair.read1method/property.BufferedRWPair.readable(self, /)—BufferedRWPair.readablemethod/property.BufferedRWPair.readinto(...)—BufferedRWPair.readintomethod/property.BufferedRWPair.readinto1(...)—BufferedRWPair.readinto1method/property.BufferedRWPair.readline(self, size=-1, /)— Read and return a line from the stream.BufferedRWPair.readlines(self, hint=-1, /)— Return a list of lines from the stream.BufferedRWPair.seek(self, offset, whence=0, /)— Change the stream position to the given byte offset.BufferedRWPair.seekable(self, /)— Return whether object supports random access.BufferedRWPair.tell(self, /)— Return current stream position.BufferedRWPair.truncate(self, size=None, /)— Truncate file to size bytes.BufferedRWPair.writable(self, /)—BufferedRWPair.writablemethod/property.BufferedRWPair.write(...)—BufferedRWPair.writemethod/property.BufferedRWPair.writelines(self, lines, /)— Write a list of lines to stream.
Usage
import io
reader = io.BytesIO(b"incoming")
writer = io.BytesIO()
pair = io.BufferedRWPair(reader, writer)
assert pair.read() == b"incoming"
pair.write(b"outgoing")
pair.flush()
assert writer.getvalue() == b"outgoing"
Gotchas
- Combines two separate raw streams: Useful for full-duplex channels (like sockets or pipes) where reads and writes go to different underlying streams—do not pass the same file handle for both (use
BufferedRandominstead).
REPL Inspect
from io import BufferedRWPair
help(BufferedRWPair)
Linked from
Related notes
- tuts/python3/stdlib_module/io/BlockingIOError Linked here; links to this page; shared tags: #io, #stdlib
- tuts/python3/stdlib_module/io/BufferedIOBase Linked here; links to this page; shared tags: #io, #stdlib
- tuts/python3/stdlib_module/io/BufferedRandom Linked here; links to this page; shared tags: #io, #stdlib
- tuts/python3/stdlib_module/io/BufferedReader Linked here; links to this page; shared tags: #io, #stdlib
- tuts/python3/stdlib_module/io/BufferedWriter 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/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
- tuts/cpp/stdlib/io_and_filesystem/iostream shared tags: #io, #stdlib