On this page
io.TextIOBase
Prev: io.text_encoding | Up: io | Next: io.TextIOWrapper
Rel: io.BlockingIOError, io.BufferedIOBase, io.BufferedRandom, io.BufferedReader
Ref: docs.python.org — io.TextIOBase
Tags: #public #python3 #stdlib #io
Import
import io
from io import TextIOBase
Signature & Overview
io.TextIOBase()
Base class for text I/O.
Methods & Attributes
TextIOBase.close(self, /)— Flush and close the IO object.TextIOBase.detach(self, /)— Separate the underlying buffer from the TextIOBase and return it.TextIOBase.fileno(self, /)— Return underlying file descriptor if one exists.TextIOBase.flush(self, /)— Flush write buffers, if applicable.TextIOBase.isatty(self, /)— Return whether this is an 'interactive' stream.TextIOBase.read(self, size=-1, /)— Read at most size characters from stream.TextIOBase.readable(self, /)— Return whether object was opened for reading.TextIOBase.readline(self, size=-1, /)— Read until newline or EOF.TextIOBase.readlines(self, hint=-1, /)— Return a list of lines from the stream.TextIOBase.seek(self, offset, whence=0, /)— Change the stream position to the given byte offset.TextIOBase.seekable(self, /)— Return whether object supports random access.TextIOBase.tell(self, /)— Return current stream position.TextIOBase.truncate(self, size=None, /)— Truncate file to size bytes.TextIOBase.writable(self, /)— Return whether object was opened for writing.TextIOBase.write(self, s, /)— Write string s to stream.TextIOBase.writelines(self, lines, /)— Write a list of lines to stream.
Usage
import io
assert isinstance(io.StringIO("hi"), io.TextIOBase)
Gotchas
- Abstract base class for character streams: Both
StringIOandTextIOWrapper(returned by textopen()) inherit fromTextIOBase.
REPL Inspect
from io import TextIOBase
help(TextIOBase)
Linked from
Related notes
- tuts/python3/stdlib_module/io/text_encoding Linked here; links to this page; shared tags: #io, #stdlib
- tuts/python3/stdlib_module/io/TextIOWrapper 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