| |
- _io._BufferedIOBase(_io._IOBase)
-
- _io.BufferedRWPair
- _io.BufferedRandom
- _io.BufferedReader
- _io.BufferedWriter
- _io.BytesIO
- BufferedIOBase(_io._BufferedIOBase, IOBase)
- _io._IOBase(__builtin__.object)
-
- IOBase
-
- BufferedIOBase(_io._BufferedIOBase, IOBase)
- RawIOBase(_io._RawIOBase, IOBase)
- TextIOBase(_io._TextIOBase, IOBase)
- _io._RawIOBase(_io._IOBase)
-
- _io.FileIO
- RawIOBase(_io._RawIOBase, IOBase)
- _io._TextIOBase(_io._IOBase)
-
- _io.StringIO
- _io.TextIOWrapper
- TextIOBase(_io._TextIOBase, IOBase)
- exceptions.IOError(exceptions.EnvironmentError)
-
- __builtin__.BlockingIOError
- UnsupportedOperation(exceptions.ValueError, exceptions.IOError)
- exceptions.ValueError(exceptions.StandardError)
-
- UnsupportedOperation(exceptions.ValueError, exceptions.IOError)
class BufferedIOBase(_io._BufferedIOBase, IOBase) |
|
Base class for buffered IO objects.
The main difference with RawIOBase is that the read() method
supports omitting the size argument, and does not have a default
implementation that defers to readinto().
In addition, read(), readinto() and write() may raise
BlockingIOError if the underlying raw stream is in non-blocking
mode and not ready; unlike their raw counterparts, they will never
return None.
A typical implementation should not inherit from a RawIOBase
implementation, but wrap one. |
|
- Method resolution order:
- BufferedIOBase
- _io._BufferedIOBase
- IOBase
- _io._IOBase
- __builtin__.object
Data and other attributes defined here:
- __abstractmethods__ = frozenset([])
Methods inherited from _io._BufferedIOBase:
- detach(...)
- Disconnect this buffer from its underlying raw stream and return it.
After the raw stream has been detached, the buffer is in an unusable
state.
- read(...)
- Read and return up to n bytes.
If the argument is omitted, None, or negative, reads and
returns all data until EOF.
If the argument is positive, and the underlying raw stream is
not 'interactive', multiple raw reads may be issued to satisfy
the byte count (unless EOF is reached first). But for
interactive raw streams (as well as sockets and pipes), at most
one raw read will be issued, and a short result does not imply
that EOF is imminent.
Returns an empty bytes object on EOF.
Returns None if the underlying raw stream was open in non-blocking
mode and no data is available at the moment.
- read1(...)
- Read and return up to n bytes, with at most one read() call
to the underlying raw stream. A short result does not imply
that EOF is imminent.
Returns an empty bytes object on EOF.
- readinto(...)
- write(...)
- Write the given buffer to the IO stream.
Returns the number of bytes written, which is never less than
len(b).
Raises BlockingIOError if the buffer is full and the
underlying raw stream cannot accept more data at the moment.
Data and other attributes inherited from IOBase:
- __metaclass__ = <class 'abc.ABCMeta'>
- Metaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed
directly, and then acts as a mix-in class. You can also register
unrelated concrete classes (even built-in classes) and unrelated
ABCs as 'virtual subclasses' -- these and their descendants will
be considered subclasses of the registering ABC by the built-in
issubclass() function, but the registering ABC won't show up in
their MRO (Method Resolution Order) nor will method
implementations defined by the registering ABC be callable (not
even via super()).
Methods inherited from _io._IOBase:
- __enter__(...)
- __exit__(...)
- __iter__(...)
- x.__iter__() <==> iter(x)
- close(...)
- Flush and close the IO object.
This method has no effect if the file is already closed.
- fileno(...)
- Returns underlying file descriptor if one exists.
An IOError is raised if the IO object does not use a file descriptor.
- flush(...)
- Flush write buffers, if applicable.
This is not implemented for read-only and non-blocking streams.
- isatty(...)
- Return whether this is an 'interactive' stream.
Return False if it can't be determined.
- next(...)
- x.next() -> the next value, or raise StopIteration
- readable(...)
- Return whether object was opened for reading.
If False, read() will raise IOError.
- readline(...)
- Read and return a line from the stream.
If limit is specified, at most limit bytes will be read.
The line terminator is always b'\n' for binary files; for text
files, the newlines argument to open can be used to select the line
terminator(s) recognized.
- readlines(...)
- Return a list of lines from the stream.
hint can be specified to control the number of lines read: no more
lines will be read if the total size (in bytes/characters) of all
lines so far exceeds hint.
- seek(...)
- Change stream position.
Change the stream position to the given byte offset. The offset is
interpreted relative to the position indicated by whence. Values
for whence are:
* 0 -- start of stream (the default); offset should be zero or positive
* 1 -- current stream position; offset may be negative
* 2 -- end of stream; offset is usually negative
Return the new absolute position.
- seekable(...)
- Return whether object supports random access.
If False, seek(), tell() and truncate() will raise IOError.
This method may need to do a test seek().
- tell(...)
- Return current stream position.
- truncate(...)
- Truncate file to size bytes.
File pointer is left unchanged. Size defaults to the current IO
position as reported by tell(). Returns the new size.
- writable(...)
- Return whether object was opened for writing.
If False, read() will raise IOError.
- writelines(...)
Data descriptors inherited from _io._IOBase:
- closed
Data and other attributes inherited from _io._IOBase:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
|
class BufferedRWPair(_BufferedIOBase) |
|
A buffered reader and writer object together.
A buffered reader object and buffered writer object put together to
form a sequential IO object that can read and write. This is typically
used with a socket or two-way pipe.
reader and writer are RawIOBase objects that are readable and
writeable respectively. If the buffer_size is omitted it defaults to
DEFAULT_BUFFER_SIZE. |
|
- Method resolution order:
- BufferedRWPair
- _BufferedIOBase
- _IOBase
- __builtin__.object
Methods defined here:
- __init__(...)
- x.__init__(...) initializes x; see help(type(x)) for signature
- close(...)
- flush(...)
- isatty(...)
- peek(...)
- read(...)
- read1(...)
- readable(...)
- readinto(...)
- writable(...)
- write(...)
Data descriptors defined here:
- closed
Data and other attributes defined here:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
Methods inherited from _BufferedIOBase:
- detach(...)
- Disconnect this buffer from its underlying raw stream and return it.
After the raw stream has been detached, the buffer is in an unusable
state.
Methods inherited from _IOBase:
- __enter__(...)
- __exit__(...)
- __iter__(...)
- x.__iter__() <==> iter(x)
- fileno(...)
- Returns underlying file descriptor if one exists.
An IOError is raised if the IO object does not use a file descriptor.
- next(...)
- x.next() -> the next value, or raise StopIteration
- readline(...)
- Read and return a line from the stream.
If limit is specified, at most limit bytes will be read.
The line terminator is always b'\n' for binary files; for text
files, the newlines argument to open can be used to select the line
terminator(s) recognized.
- readlines(...)
- Return a list of lines from the stream.
hint can be specified to control the number of lines read: no more
lines will be read if the total size (in bytes/characters) of all
lines so far exceeds hint.
- seek(...)
- Change stream position.
Change the stream position to the given byte offset. The offset is
interpreted relative to the position indicated by whence. Values
for whence are:
* 0 -- start of stream (the default); offset should be zero or positive
* 1 -- current stream position; offset may be negative
* 2 -- end of stream; offset is usually negative
Return the new absolute position.
- seekable(...)
- Return whether object supports random access.
If False, seek(), tell() and truncate() will raise IOError.
This method may need to do a test seek().
- tell(...)
- Return current stream position.
- truncate(...)
- Truncate file to size bytes.
File pointer is left unchanged. Size defaults to the current IO
position as reported by tell(). Returns the new size.
- writelines(...)
|
class BufferedWriter(_BufferedIOBase) |
|
A buffer for a writeable sequential RawIO object.
The constructor creates a BufferedWriter for the given writeable raw
stream. If the buffer_size is not given, it defaults to
DEFAULT_BUFFER_SIZE. max_buffer_size isn't used anymore. |
|
- Method resolution order:
- BufferedWriter
- _BufferedIOBase
- _IOBase
- __builtin__.object
Methods defined here:
- __init__(...)
- x.__init__(...) initializes x; see help(type(x)) for signature
- __repr__(...)
- x.__repr__() <==> repr(x)
- __sizeof__(...)
- close(...)
- detach(...)
- fileno(...)
- flush(...)
- isatty(...)
- readable(...)
- seek(...)
- seekable(...)
- tell(...)
- truncate(...)
- writable(...)
- write(...)
Data descriptors defined here:
- closed
- mode
- name
- raw
Data and other attributes defined here:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
Methods inherited from _BufferedIOBase:
- read(...)
- Read and return up to n bytes.
If the argument is omitted, None, or negative, reads and
returns all data until EOF.
If the argument is positive, and the underlying raw stream is
not 'interactive', multiple raw reads may be issued to satisfy
the byte count (unless EOF is reached first). But for
interactive raw streams (as well as sockets and pipes), at most
one raw read will be issued, and a short result does not imply
that EOF is imminent.
Returns an empty bytes object on EOF.
Returns None if the underlying raw stream was open in non-blocking
mode and no data is available at the moment.
- read1(...)
- Read and return up to n bytes, with at most one read() call
to the underlying raw stream. A short result does not imply
that EOF is imminent.
Returns an empty bytes object on EOF.
- readinto(...)
Methods inherited from _IOBase:
- __enter__(...)
- __exit__(...)
- __iter__(...)
- x.__iter__() <==> iter(x)
- next(...)
- x.next() -> the next value, or raise StopIteration
- readline(...)
- Read and return a line from the stream.
If limit is specified, at most limit bytes will be read.
The line terminator is always b'\n' for binary files; for text
files, the newlines argument to open can be used to select the line
terminator(s) recognized.
- readlines(...)
- Return a list of lines from the stream.
hint can be specified to control the number of lines read: no more
lines will be read if the total size (in bytes/characters) of all
lines so far exceeds hint.
- writelines(...)
|
class BytesIO(_BufferedIOBase) |
|
BytesIO([buffer]) -> object
Create a buffered I/O implementation using an in-memory bytes
buffer, ready for reading and writing. |
|
- Method resolution order:
- BytesIO
- _BufferedIOBase
- _IOBase
- __builtin__.object
Methods defined here:
- __getstate__(...)
- __init__(...)
- x.__init__(...) initializes x; see help(type(x)) for signature
- __iter__(...)
- x.__iter__() <==> iter(x)
- __setstate__(...)
- __sizeof__(...)
- close(...)
- close() -> None. Disable all I/O operations.
- flush(...)
- flush() -> None. Does nothing.
- getvalue(...)
- getvalue() -> bytes.
Retrieve the entire contents of the BytesIO object.
- isatty(...)
- isatty() -> False.
Always returns False since BytesIO objects are not connected
to a tty-like device.
- next(...)
- x.next() -> the next value, or raise StopIteration
- read(...)
- read([size]) -> read at most size bytes, returned as a string.
If the size argument is negative, read until EOF is reached.
Return an empty string at EOF.
- read1(...)
- read1(size) -> read at most size bytes, returned as a string.
If the size argument is negative or omitted, read until EOF is reached.
Return an empty string at EOF.
- readable(...)
- readable() -> bool. Returns True if the IO object can be read.
- readinto(...)
- readinto(bytearray) -> int. Read up to len(b) bytes into b.
Returns number of bytes read (0 for EOF), or None if the object
is set not to block as has no data to read.
- readline(...)
- readline([size]) -> next line from the file, as a string.
Retain newline. A non-negative size argument limits the maximum
number of bytes to return (an incomplete line may be returned then).
Return an empty string at EOF.
- readlines(...)
- readlines([size]) -> list of strings, each a line from the file.
Call readline() repeatedly and return a list of the lines so read.
The optional size argument, if given, is an approximate bound on the
total number of bytes in the lines returned.
- seek(...)
- seek(pos, whence=0) -> int. Change stream position.
Seek to byte offset pos relative to position indicated by whence:
0 Start of stream (the default). pos should be >= 0;
1 Current position - pos may be negative;
2 End of stream - pos usually negative.
Returns the new absolute position.
- seekable(...)
- seekable() -> bool. Returns True if the IO object can be seeked.
- tell(...)
- tell() -> current file position, an integer
- truncate(...)
- truncate([size]) -> int. Truncate the file to at most size bytes.
Size defaults to the current file position, as returned by tell().
The current file position is unchanged. Returns the new size.
- writable(...)
- writable() -> bool. Returns True if the IO object can be written.
- write(...)
- write(bytes) -> int. Write bytes to file.
Return the number of bytes written.
- writelines(...)
- writelines(sequence_of_strings) -> None. Write strings to the file.
Note that newlines are not added. The sequence can be any iterable
object producing strings. This is equivalent to calling write() for
each string.
Data descriptors defined here:
- closed
- True if the file is closed.
Data and other attributes defined here:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
Methods inherited from _BufferedIOBase:
- detach(...)
- Disconnect this buffer from its underlying raw stream and return it.
After the raw stream has been detached, the buffer is in an unusable
state.
Methods inherited from _IOBase:
- __enter__(...)
- __exit__(...)
- fileno(...)
- Returns underlying file descriptor if one exists.
An IOError is raised if the IO object does not use a file descriptor.
|
class FileIO(_RawIOBase) |
|
file(name: str[, mode: str]) -> file IO object
Open a file. The mode can be 'r' (default), 'w' or 'a' for reading,
writing or appending. The file will be created if it doesn't exist
when opened for writing or appending; it will be truncated when
opened for writing. Add a '+' to the mode to allow simultaneous
reading and writing. |
|
- Method resolution order:
- FileIO
- _RawIOBase
- _IOBase
- __builtin__.object
Methods defined here:
- __getattribute__(...)
- x.__getattribute__('name') <==> x.name
- __init__(...)
- x.__init__(...) initializes x; see help(type(x)) for signature
- __repr__(...)
- x.__repr__() <==> repr(x)
- close(...)
- close() -> None. Close the file.
A closed file cannot be used for further I/O operations. close() may be
called more than once without error.
- fileno(...)
- fileno() -> int. Return the underlying file descriptor (an integer).
- isatty(...)
- isatty() -> bool. True if the file is connected to a TTY device.
- read(...)
- read(size: int) -> bytes. read at most size bytes, returned as bytes.
Only makes one system call, so less data may be returned than requested
In non-blocking mode, returns None if no data is available.
On end-of-file, returns ''.
- readable(...)
- readable() -> bool. True if file was opened in a read mode.
- readall(...)
- readall() -> bytes. read all data from the file, returned as bytes.
In non-blocking mode, returns as much as is immediately available,
or None if no data is available. On end-of-file, returns ''.
- readinto(...)
- readinto() -> Same as RawIOBase.readinto().
- seek(...)
- seek(offset: int[, whence: int]) -> int. Move to new file position
and return the file position.
Argument offset is a byte count. Optional argument whence defaults to
SEEK_SET or 0 (offset from start of file, offset should be >= 0); other values
are SEEK_CUR or 1 (move relative to current position, positive or negative),
and SEEK_END or 2 (move relative to end of file, usually negative, although
many platforms allow seeking beyond the end of a file).
Note that not all file objects are seekable.
- seekable(...)
- seekable() -> bool. True if file supports random-access.
- tell(...)
- tell() -> int. Current file position.
Can raise OSError for non seekable files.
- truncate(...)
- truncate([size: int]) -> int. Truncate the file to at most size bytes and
return the truncated size.
Size defaults to the current file position, as returned by tell().
The current file position is changed to the value of size.
- writable(...)
- writable() -> bool. True if file was opened in a write mode.
- write(...)
- write(b: bytes) -> int. Write bytes b to file, return number written.
Only makes one system call, so not all of the data may be written.
The number of bytes actually written is returned. In non-blocking mode,
returns None if the write would block.
Data descriptors defined here:
- closed
- True if the file is closed
- closefd
- True if the file descriptor will be closed by close().
- mode
- String giving the file mode
Data and other attributes defined here:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
Methods inherited from _IOBase:
- __enter__(...)
- __exit__(...)
- __iter__(...)
- x.__iter__() <==> iter(x)
- flush(...)
- Flush write buffers, if applicable.
This is not implemented for read-only and non-blocking streams.
- next(...)
- x.next() -> the next value, or raise StopIteration
- readline(...)
- Read and return a line from the stream.
If limit is specified, at most limit bytes will be read.
The line terminator is always b'\n' for binary files; for text
files, the newlines argument to open can be used to select the line
terminator(s) recognized.
- readlines(...)
- Return a list of lines from the stream.
hint can be specified to control the number of lines read: no more
lines will be read if the total size (in bytes/characters) of all
lines so far exceeds hint.
- writelines(...)
|
class IOBase(_io._IOBase) |
|
The abstract base class for all I/O classes, acting on streams of
bytes. There is no public constructor.
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 a IOError when operations they do not support are called.
The basic type used for binary data read from or written to a file is
bytes. bytearrays are accepted too, and in some cases (such as
readinto) needed. 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!') |
|
- Method resolution order:
- IOBase
- _io._IOBase
- __builtin__.object
Data and other attributes defined here:
- __abstractmethods__ = frozenset([])
- __metaclass__ = <class 'abc.ABCMeta'>
- Metaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed
directly, and then acts as a mix-in class. You can also register
unrelated concrete classes (even built-in classes) and unrelated
ABCs as 'virtual subclasses' -- these and their descendants will
be considered subclasses of the registering ABC by the built-in
issubclass() function, but the registering ABC won't show up in
their MRO (Method Resolution Order) nor will method
implementations defined by the registering ABC be callable (not
even via super()).
Methods inherited from _io._IOBase:
- __enter__(...)
- __exit__(...)
- __iter__(...)
- x.__iter__() <==> iter(x)
- close(...)
- Flush and close the IO object.
This method has no effect if the file is already closed.
- fileno(...)
- Returns underlying file descriptor if one exists.
An IOError is raised if the IO object does not use a file descriptor.
- flush(...)
- Flush write buffers, if applicable.
This is not implemented for read-only and non-blocking streams.
- isatty(...)
- Return whether this is an 'interactive' stream.
Return False if it can't be determined.
- next(...)
- x.next() -> the next value, or raise StopIteration
- readable(...)
- Return whether object was opened for reading.
If False, read() will raise IOError.
- readline(...)
- Read and return a line from the stream.
If limit is specified, at most limit bytes will be read.
The line terminator is always b'\n' for binary files; for text
files, the newlines argument to open can be used to select the line
terminator(s) recognized.
- readlines(...)
- Return a list of lines from the stream.
hint can be specified to control the number of lines read: no more
lines will be read if the total size (in bytes/characters) of all
lines so far exceeds hint.
- seek(...)
- Change stream position.
Change the stream position to the given byte offset. The offset is
interpreted relative to the position indicated by whence. Values
for whence are:
* 0 -- start of stream (the default); offset should be zero or positive
* 1 -- current stream position; offset may be negative
* 2 -- end of stream; offset is usually negative
Return the new absolute position.
- seekable(...)
- Return whether object supports random access.
If False, seek(), tell() and truncate() will raise IOError.
This method may need to do a test seek().
- tell(...)
- Return current stream position.
- truncate(...)
- Truncate file to size bytes.
File pointer is left unchanged. Size defaults to the current IO
position as reported by tell(). Returns the new size.
- writable(...)
- Return whether object was opened for writing.
If False, read() will raise IOError.
- writelines(...)
Data descriptors inherited from _io._IOBase:
- closed
Data and other attributes inherited from _io._IOBase:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
|
class RawIOBase(_io._RawIOBase, IOBase) |
|
Base class for raw binary I/O. |
|
- Method resolution order:
- RawIOBase
- _io._RawIOBase
- IOBase
- _io._IOBase
- __builtin__.object
Data and other attributes defined here:
- __abstractmethods__ = frozenset([])
Methods inherited from _io._RawIOBase:
- read(...)
- readall(...)
- Read until EOF, using multiple read() call.
Data and other attributes inherited from IOBase:
- __metaclass__ = <class 'abc.ABCMeta'>
- Metaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed
directly, and then acts as a mix-in class. You can also register
unrelated concrete classes (even built-in classes) and unrelated
ABCs as 'virtual subclasses' -- these and their descendants will
be considered subclasses of the registering ABC by the built-in
issubclass() function, but the registering ABC won't show up in
their MRO (Method Resolution Order) nor will method
implementations defined by the registering ABC be callable (not
even via super()).
Methods inherited from _io._IOBase:
- __enter__(...)
- __exit__(...)
- __iter__(...)
- x.__iter__() <==> iter(x)
- close(...)
- Flush and close the IO object.
This method has no effect if the file is already closed.
- fileno(...)
- Returns underlying file descriptor if one exists.
An IOError is raised if the IO object does not use a file descriptor.
- flush(...)
- Flush write buffers, if applicable.
This is not implemented for read-only and non-blocking streams.
- isatty(...)
- Return whether this is an 'interactive' stream.
Return False if it can't be determined.
- next(...)
- x.next() -> the next value, or raise StopIteration
- readable(...)
- Return whether object was opened for reading.
If False, read() will raise IOError.
- readline(...)
- Read and return a line from the stream.
If limit is specified, at most limit bytes will be read.
The line terminator is always b'\n' for binary files; for text
files, the newlines argument to open can be used to select the line
terminator(s) recognized.
- readlines(...)
- Return a list of lines from the stream.
hint can be specified to control the number of lines read: no more
lines will be read if the total size (in bytes/characters) of all
lines so far exceeds hint.
- seek(...)
- Change stream position.
Change the stream position to the given byte offset. The offset is
interpreted relative to the position indicated by whence. Values
for whence are:
* 0 -- start of stream (the default); offset should be zero or positive
* 1 -- current stream position; offset may be negative
* 2 -- end of stream; offset is usually negative
Return the new absolute position.
- seekable(...)
- Return whether object supports random access.
If False, seek(), tell() and truncate() will raise IOError.
This method may need to do a test seek().
- tell(...)
- Return current stream position.
- truncate(...)
- Truncate file to size bytes.
File pointer is left unchanged. Size defaults to the current IO
position as reported by tell(). Returns the new size.
- writable(...)
- Return whether object was opened for writing.
If False, read() will raise IOError.
- writelines(...)
Data descriptors inherited from _io._IOBase:
- closed
Data and other attributes inherited from _io._IOBase:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
|
class StringIO(_TextIOBase) |
|
Text I/O implementation using an in-memory buffer.
The initial_value argument sets the value of object. The newline
argument is like the one of TextIOWrapper's constructor. |
|
- Method resolution order:
- StringIO
- _TextIOBase
- _IOBase
- __builtin__.object
Methods defined here:
- __getstate__(...)
- __init__(...)
- x.__init__(...) initializes x; see help(type(x)) for signature
- __setstate__(...)
- close(...)
- Close the IO object. Attempting any further operation after the
object is closed will raise a ValueError.
This method has no effect if the file is already closed.
- getvalue(...)
- Retrieve the entire contents of the object.
- next(...)
- x.next() -> the next value, or raise StopIteration
- read(...)
- Read at most n characters, returned as a string.
If the argument is negative or omitted, read until EOF
is reached. Return an empty string at EOF.
- readable(...)
- readable() -> bool. Returns True if the IO object can be read.
- readline(...)
- Read until newline or EOF.
Returns an empty string if EOF is hit immediately.
- seek(...)
- Change stream position.
Seek to character offset pos relative to position indicated by whence:
0 Start of stream (the default). pos should be >= 0;
1 Current position - pos must be 0;
2 End of stream - pos must be 0.
Returns the new absolute position.
- seekable(...)
- seekable() -> bool. Returns True if the IO object can be seeked.
- tell(...)
- Tell the current file position.
- truncate(...)
- Truncate size to pos.
The pos argument defaults to the current file position, as
returned by tell(). The current file position is unchanged.
Returns the new absolute position.
- writable(...)
- writable() -> bool. Returns True if the IO object can be written.
- write(...)
- Write string to file.
Returns the number of characters written, which is always equal to
the length of the string.
Data descriptors defined here:
- closed
- line_buffering
- newlines
Data and other attributes defined here:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
Methods inherited from _TextIOBase:
- detach(...)
- Separate the underlying buffer from the TextIOBase and return it.
After the underlying buffer has been detached, the TextIO is in an
unusable state.
Data descriptors inherited from _TextIOBase:
- encoding
- Encoding of the text stream.
Subclasses should override.
- errors
- The error setting of the decoder or encoder.
Subclasses should override.
Methods inherited from _IOBase:
- __enter__(...)
- __exit__(...)
- __iter__(...)
- x.__iter__() <==> iter(x)
- fileno(...)
- Returns underlying file descriptor if one exists.
An IOError is raised if the IO object does not use a file descriptor.
- flush(...)
- Flush write buffers, if applicable.
This is not implemented for read-only and non-blocking streams.
- isatty(...)
- Return whether this is an 'interactive' stream.
Return False if it can't be determined.
- readlines(...)
- Return a list of lines from the stream.
hint can be specified to control the number of lines read: no more
lines will be read if the total size (in bytes/characters) of all
lines so far exceeds hint.
- writelines(...)
|
class TextIOBase(_io._TextIOBase, IOBase) |
|
Base class for text I/O.
This class provides a character and line based interface to stream
I/O. There is no readinto method because Python's character strings
are immutable. There is no public constructor. |
|
- Method resolution order:
- TextIOBase
- _io._TextIOBase
- IOBase
- _io._IOBase
- __builtin__.object
Data and other attributes defined here:
- __abstractmethods__ = frozenset([])
Methods inherited from _io._TextIOBase:
- detach(...)
- Separate the underlying buffer from the TextIOBase and return it.
After the underlying buffer has been detached, the TextIO is in an
unusable state.
- read(...)
- Read at most n characters from stream.
Read from underlying buffer until we have n characters or we hit EOF.
If n is negative or omitted, read until EOF.
- readline(...)
- Read until newline or EOF.
Returns an empty string if EOF is hit immediately.
- write(...)
- Write string to stream.
Returns the number of characters written (which is always equal to
the length of the string).
Data descriptors inherited from _io._TextIOBase:
- encoding
- Encoding of the text stream.
Subclasses should override.
- errors
- The error setting of the decoder or encoder.
Subclasses should override.
- newlines
- Line endings translated so far.
Only line endings translated during reading are considered.
Subclasses should override.
Data and other attributes inherited from IOBase:
- __metaclass__ = <class 'abc.ABCMeta'>
- Metaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed
directly, and then acts as a mix-in class. You can also register
unrelated concrete classes (even built-in classes) and unrelated
ABCs as 'virtual subclasses' -- these and their descendants will
be considered subclasses of the registering ABC by the built-in
issubclass() function, but the registering ABC won't show up in
their MRO (Method Resolution Order) nor will method
implementations defined by the registering ABC be callable (not
even via super()).
Methods inherited from _io._IOBase:
- __enter__(...)
- __exit__(...)
- __iter__(...)
- x.__iter__() <==> iter(x)
- close(...)
- Flush and close the IO object.
This method has no effect if the file is already closed.
- fileno(...)
- Returns underlying file descriptor if one exists.
An IOError is raised if the IO object does not use a file descriptor.
- flush(...)
- Flush write buffers, if applicable.
This is not implemented for read-only and non-blocking streams.
- isatty(...)
- Return whether this is an 'interactive' stream.
Return False if it can't be determined.
- next(...)
- x.next() -> the next value, or raise StopIteration
- readable(...)
- Return whether object was opened for reading.
If False, read() will raise IOError.
- readlines(...)
- Return a list of lines from the stream.
hint can be specified to control the number of lines read: no more
lines will be read if the total size (in bytes/characters) of all
lines so far exceeds hint.
- seek(...)
- Change stream position.
Change the stream position to the given byte offset. The offset is
interpreted relative to the position indicated by whence. Values
for whence are:
* 0 -- start of stream (the default); offset should be zero or positive
* 1 -- current stream position; offset may be negative
* 2 -- end of stream; offset is usually negative
Return the new absolute position.
- seekable(...)
- Return whether object supports random access.
If False, seek(), tell() and truncate() will raise IOError.
This method may need to do a test seek().
- tell(...)
- Return current stream position.
- truncate(...)
- Truncate file to size bytes.
File pointer is left unchanged. Size defaults to the current IO
position as reported by tell(). Returns the new size.
- writable(...)
- Return whether object was opened for writing.
If False, read() will raise IOError.
- writelines(...)
Data descriptors inherited from _io._IOBase:
- closed
Data and other attributes inherited from _io._IOBase:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
|
class TextIOWrapper(_TextIOBase) |
|
Character and line based layer over a BufferedIOBase object, buffer.
encoding gives the name of the encoding that the stream will be
decoded or encoded with. It defaults to locale.getpreferredencoding.
errors determines the strictness of encoding and decoding (see the
codecs.register) and defaults to "strict".
newline controls how line endings are handled. It can be None, '',
'\n', '\r', and '\r\n'. It works as follows:
* On input, if newline is None, universal newlines mode is
enabled. Lines in the input can end in '\n', '\r', or '\r\n', and
these are translated into '\n' before being returned to the
caller. If it is '', universal newline mode is enabled, but line
endings are returned to the caller untranslated. If it has any of
the other legal values, input lines are only terminated by the given
string, and the line ending is returned to the caller untranslated.
* On output, if newline is None, any '\n' characters written are
translated to the system default line separator, os.linesep. If
newline is '', no translation takes place. If newline is any of the
other legal values, any '\n' characters written are translated to
the given string.
If line_buffering is True, a call to flush is implied when a call to
write contains a newline character. |
|
- Method resolution order:
- TextIOWrapper
- _TextIOBase
- _IOBase
- __builtin__.object
Methods defined here:
- __init__(...)
- x.__init__(...) initializes x; see help(type(x)) for signature
- __repr__(...)
- x.__repr__() <==> repr(x)
- close(...)
- detach(...)
- fileno(...)
- flush(...)
- isatty(...)
- next(...)
- x.next() -> the next value, or raise StopIteration
- read(...)
- readable(...)
- readline(...)
- seek(...)
- seekable(...)
- tell(...)
- truncate(...)
- writable(...)
- write(...)
Data descriptors defined here:
- buffer
- closed
- encoding
- errors
- line_buffering
- name
- newlines
Data and other attributes defined here:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
Methods inherited from _IOBase:
- __enter__(...)
- __exit__(...)
- __iter__(...)
- x.__iter__() <==> iter(x)
- readlines(...)
- Return a list of lines from the stream.
hint can be specified to control the number of lines read: no more
lines will be read if the total size (in bytes/characters) of all
lines so far exceeds hint.
- writelines(...)
|
|