PyDocs

Nav

Generic Operating System Services

IOBase

io

class (source)
The abstract base class for all I/O classes.

This class provides dummy implementations for many methods that
derived classes can override selectively; the default implementations
represent a file that cannot be read, written or seeked.

Even though IOBase does not declare read, readinto, or write because
their signatures will vary, implementations and clients should
consider those methods part of the interface. Also, implementations
may raise UnsupportedOperation when operations they do not support are
called.

The basic type used for binary data read from or written to a file is
bytes. Other bytes-like objects are accepted as method arguments too.
In some cases (such as readinto), a writable object is required. Text
I/O classes work with str data.

Note that calling any method (except additional calls to close(),
which are ignored) on a closed stream should raise a ValueError.

IOBase (and its subclasses) support the iterator protocol, meaning
that an IOBase object can be iterated over yielding the lines in a
stream.

IOBase also supports the :keyword:`with` statement. In this example,
fp is closed after the suite of the with statement is complete:

with open('spam.txt', 'r') as fp:
    fp.write('Spam and eggs!')
Members of IOBase

_

__del__
Called when the instance is about to be destroyed.

c

close
Flush and close the IO object.
closed
True if the stream is closed.

f

fileno
Return underlying file descriptor if one exists.
flush
Flush write buffers, if applicable.

i

isatty
Return whether this is an 'interactive' stream.

r

readable
Return whether object was opened for reading.
readline
Read and return a line from the stream.
readlines
Return a list of lines from the stream.

s

seek
Change the stream position to the given byte offset.
seekable
Return whether object supports random access.

t

tell
Return current stream position.
truncate
Truncate file to size bytes.

w

writable
Return whether object was opened for writing.
writelines
Write a list of lines to stream.
0 Examples
No examples for io/IOBase.
See Also
No see-alsos for io/IOBase
0 Notes
No notes for IOBase