io API Reference
Full documentation for io (Standard Library / Native)
io.BlockingIOError
Python Library Documentation: class BlockingIOError in module builtins class BlockingIOError(OSError) | I/O operation would block. | | Method resolution order: | BlockingIOError | OSError | Exception | BaseException | object | | Methods defined here: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from OSError: | | __reduce__(...) | Helper for pickle. | | __str__(self, /) | Return str(self). | | ---------------------------------------------------------------------- | Static methods inherited from OSError: | | __new__(*args, **kwargs) class method of builtins.OSError | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from OSError: | | characters_written | | errno | POSIX exception code | | filename | exception filename | | filename2 | second exception filename | | strerror | exception strerror | | winerror | Win32 exception code | | ---------------------------------------------------------------------- | Methods inherited from BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
io.BufferedIOBase
Python Library Documentation: class BufferedIOBase in module io 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 | builtins.object | | Data and other attributes defined here: | | __abstractmethods__ = frozenset() | | ---------------------------------------------------------------------- | Methods inherited from _io._BufferedIOBase: | | detach(self, /) | 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(self, size=-1, /) | Read and return up to n bytes. | | If the size argument is omitted, None, or negative, read and | return all data until EOF. | | If the size 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). | However, 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. | | Return an empty bytes object on EOF. | | Return None if the underlying raw stream was open in non-blocking | mode and no data is available at the moment. | | read1(self, size=-1, /) | Read and return up to size bytes, with at most one read() call to the underlying raw stream. | | Return an empty bytes object on EOF. | A short result does not imply that EOF is imminent. | | readinto(self, buffer, /) | | readinto1(self, buffer, /) | | write(self, b, /) | Write buffer b to the IO stream. | | Return the number of bytes written, which is always | the length of b in bytes. | | Raise BlockingIOError if the buffer is full and the | underlying raw stream cannot accept more data at the moment. | | ---------------------------------------------------------------------- | Methods inherited from _io._IOBase: | | __del__(...) | | __enter__(...) | | __exit__(...) | | __iter__(self, /) | Implement iter(self). | | __next__(self, /) | Implement next(self). | | close(self, /) | Flush and close the IO object. | | This method has no effect if the file is already closed. | | fileno(self, /) | Return underlying file descriptor if one exists. | | Raise OSError if the IO object does not use a file descriptor. | | flush(self, /) | Flush write buffers, if applicable. | | This is not implemented for read-only and non-blocking streams. | | isatty(self, /) | Return whether this is an 'interactive' stream. | | Return False if it can't be determined. | | readable(self, /) | Return whether object was opened for reading. | | If False, read() will raise OSError. | | readline(self, size=-1, /) | Read and return a line from the stream. | | If size is specified, at most size 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(self, hint=-1, /) | 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(self, offset, whence=0, /) | Change the stream position to the given byte offset. | | offset | The stream position, relative to 'whence'. | whence | The relative position to seek from. | | The offset is interpreted relative to the position indicated by whence. | Values for whence are: | | * os.SEEK_SET or 0 -- start of stream (the default); offset should be zero or positive | * os.SEEK_CUR or 1 -- current stream position; offset may be negative | * os.SEEK_END or 2 -- end of stream; offset is usually negative | | Return the new absolute position. | | seekable(self, /) | Return whether object supports random access. | | If False, seek(), tell() and truncate() will raise OSError. | This method may need to do a test seek(). | | tell(self, /) | Return current stream position. | | truncate(self, size=None, /) | Truncate file to size bytes. | | File pointer is left unchanged. Size defaults to the current IO position | as reported by tell(). Return the new size. | | writable(self, /) | Return whether object was opened for writing. | | If False, write() will raise OSError. | | writelines(self, lines, /) | Write a list of lines to stream. | | Line separators are not added, so it is usual for each of the | lines provided to have a line separator at the end. | | ---------------------------------------------------------------------- | Data descriptors inherited from _io._IOBase: | | __dict__ | | closed
io.BufferedRWPair
Python Library Documentation: class BufferedRWPair in module _io class BufferedRWPair(_BufferedIOBase) | BufferedRWPair(reader, writer, buffer_size=8192, /) | | 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 | builtins.object | | Methods defined here: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | close(...) | Flush and close the IO object. | | This method has no effect if the file is already closed. | | 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. | | peek(...) | | read(...) | Read and return up to n bytes. | | If the size argument is omitted, None, or negative, read and | return all data until EOF. | | If the size 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). | However, 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. | | Return an empty bytes object on EOF. | | Return 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 size bytes, with at most one read() call to the underlying raw stream. | | Return an empty bytes object on EOF. | A short result does not imply that EOF is imminent. | | readable(...) | Return whether object was opened for reading. | | If False, read() will raise OSError. | | readinto(...) | | readinto1(...) | | writable(...) | Return whether object was opened for writing. | | If False, write() will raise OSError. | | write(...) | Write buffer b to the IO stream. | | Return the number of bytes written, which is always | the length of b in bytes. | | Raise BlockingIOError if the buffer is full and the | underlying raw stream cannot accept more data at the moment. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | closed | | ---------------------------------------------------------------------- | Methods inherited from _BufferedIOBase: | | detach(self, /) | 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: | | __del__(...) | | __enter__(...) | | __exit__(...) | | __iter__(self, /) | Implement iter(self). | | __next__(self, /) | Implement next(self). | | fileno(self, /) | Return underlying file descriptor if one exists. | | Raise OSError if the IO object does not use a file descriptor. | | readline(self, size=-1, /) | Read and return a line from the stream. | | If size is specified, at most size 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(self, hint=-1, /) | 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(self, offset, whence=0, /) | Change the stream position to the given byte offset. | | offset | The stream position, relative to 'whence'. | whence | The relative position to seek from. | | The offset is interpreted relative to the position indicated by whence. | Values for whence are: | | * os.SEEK_SET or 0 -- start of stream (the default); offset should be zero or positive | * os.SEEK_CUR or 1 -- current stream position; offset may be negative | * os.SEEK_END or 2 -- end of stream; offset is usually negative | | Return the new absolute position. | | seekable(self, /) | Return whether object supports random access. | | If False, seek(), tell() and truncate() will raise OSError. | This method may need to do a test seek(). | | tell(self, /) | Return current stream position. | | truncate(self, size=None, /) | Truncate file to size bytes. | | File pointer is left unchanged. Size defaults to the current IO position | as reported by tell(). Return the new size. | | writelines(self, lines, /) | Write a list of lines to stream. | | Line separators are not added, so it is usual for each of the | lines provided to have a line separator at the end. | | ---------------------------------------------------------------------- | Data descriptors inherited from _IOBase: | | __dict__
io.BufferedRandom
Python Library Documentation: class BufferedRandom in module _io class BufferedRandom(_BufferedIOBase) | BufferedRandom(raw, buffer_size=8192) | | A buffered interface to random access streams. | | The constructor creates a reader and writer for a seekable stream, | raw, given in the first argument. If the buffer_size is omitted it | defaults to DEFAULT_BUFFER_SIZE. | | Method resolution order: | BufferedRandom | _BufferedIOBase | _IOBase | builtins.object | | Methods defined here: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __next__(self, /) | Implement next(self). | | __reduce__(...) | Helper for pickle. | | __reduce_ex__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __sizeof__(self, /) | Size of object in memory, in bytes. | | close(self, /) | Flush and close the IO object. | | This method has no effect if the file is already closed. | | detach(self, /) | 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. | | fileno(self, /) | Return underlying file descriptor if one exists. | | Raise OSError if the IO object does not use a file descriptor. | | flush(self, /) | Flush write buffers, if applicable. | | This is not implemented for read-only and non-blocking streams. | | isatty(self, /) | Return whether this is an 'interactive' stream. | | Return False if it can't be determined. | | peek(self, size=0, /) | | read(self, size=-1, /) | Read and return up to n bytes. | | If the size argument is omitted, None, or negative, read and | return all data until EOF. | | If the size 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). | However, 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. | | Return an empty bytes object on EOF. | | Return None if the underlying raw stream was open in non-blocking | mode and no data is available at the moment. | | read1(self, size=-1, /) | Read and return up to size bytes, with at most one read() call to the underlying raw stream. | | Return an empty bytes object on EOF. | A short result does not imply that EOF is imminent. | | readable(self, /) | Return whether object was opened for reading. | | If False, read() will raise OSError. | | readinto(self, buffer, /) | | readinto1(self, buffer, /) | | readline(self, size=-1, /) | Read and return a line from the stream. | | If size is specified, at most size 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. | | seek(self, target, whence=0, /) | Change the stream position to the given byte offset. | | offset | The stream position, relative to 'whence'. | whence | The relative position to seek from. | | The offset is interpreted relative to the position indicated by whence. | Values for whence are: | | * os.SEEK_SET or 0 -- start of stream (the default); offset should be zero or positive | * os.SEEK_CUR or 1 -- current stream position; offset may be negative | * os.SEEK_END or 2 -- end of stream; offset is usually negative | | Return the new absolute position. | | seekable(self, /) | Return whether object supports random access. | | If False, seek(), tell() and truncate() will raise OSError. | This method may need to do a test seek(). | | tell(self, /) | Return current stream position. | | truncate(self, pos=None, /) | Truncate file to size bytes. | | File pointer is left unchanged. Size defaults to the current IO position | as reported by tell(). Return the new size. | | writable(self, /) | Return whether object was opened for writing. | | If False, write() will raise OSError. | | write(self, buffer, /) | Write buffer b to the IO stream. | | Return the number of bytes written, which is always | the length of b in bytes. | | Raise BlockingIOError if the buffer is full and the | underlying raw stream cannot accept more data at the moment. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | closed | | mode | | name | | raw | | ---------------------------------------------------------------------- | Methods inherited from _IOBase: | | __del__(...) | | __enter__(...) | | __exit__(...) | | __iter__(self, /) | Implement iter(self). | | readlines(self, hint=-1, /) | 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(self, lines, /) | Write a list of lines to stream. | | Line separators are not added, so it is usual for each of the | lines provided to have a line separator at the end. | | ---------------------------------------------------------------------- | Data descriptors inherited from _IOBase: | | __dict__
io.BufferedReader
Python Library Documentation: class BufferedReader in module _io class BufferedReader(_BufferedIOBase) | BufferedReader(raw, buffer_size=8192) | | Create a new buffered reader using the given readable raw IO object. | | Method resolution order: | BufferedReader | _BufferedIOBase | _IOBase | builtins.object | | Methods defined here: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __next__(self, /) | Implement next(self). | | __reduce__(...) | Helper for pickle. | | __reduce_ex__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __sizeof__(self, /) | Size of object in memory, in bytes. | | close(self, /) | Flush and close the IO object. | | This method has no effect if the file is already closed. | | detach(self, /) | 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. | | fileno(self, /) | Return underlying file descriptor if one exists. | | Raise OSError if the IO object does not use a file descriptor. | | flush(self, /) | Flush write buffers, if applicable. | | This is not implemented for read-only and non-blocking streams. | | isatty(self, /) | Return whether this is an 'interactive' stream. | | Return False if it can't be determined. | | peek(self, size=0, /) | | read(self, size=-1, /) | Read and return up to n bytes. | | If the size argument is omitted, None, or negative, read and | return all data until EOF. | | If the size 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). | However, 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. | | Return an empty bytes object on EOF. | | Return None if the underlying raw stream was open in non-blocking | mode and no data is available at the moment. | | read1(self, size=-1, /) | Read and return up to size bytes, with at most one read() call to the underlying raw stream. | | Return an empty bytes object on EOF. | A short result does not imply that EOF is imminent. | | readable(self, /) | Return whether object was opened for reading. | | If False, read() will raise OSError. | | readinto(self, buffer, /) | | readinto1(self, buffer, /) | | readline(self, size=-1, /) | Read and return a line from the stream. | | If size is specified, at most size 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. | | seek(self, target, whence=0, /) | Change the stream position to the given byte offset. | | offset | The stream position, relative to 'whence'. | whence | The relative position to seek from. | | The offset is interpreted relative to the position indicated by whence. | Values for whence are: | | * os.SEEK_SET or 0 -- start of stream (the default); offset should be zero or positive | * os.SEEK_CUR or 1 -- current stream position; offset may be negative | * os.SEEK_END or 2 -- end of stream; offset is usually negative | | Return the new absolute position. | | seekable(self, /) | Return whether object supports random access. | | If False, seek(), tell() and truncate() will raise OSError. | This method may need to do a test seek(). | | tell(self, /) | Return current stream position. | | truncate(self, pos=None, /) | Truncate file to size bytes. | | File pointer is left unchanged. Size defaults to the current IO position | as reported by tell(). Return the new size. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | closed | | mode | | name | | raw | | ---------------------------------------------------------------------- | Methods inherited from _BufferedIOBase: | | write(self, b, /) | Write buffer b to the IO stream. | | Return the number of bytes written, which is always | the length of b in bytes. | | Raise BlockingIOError if the buffer is full and the | underlying raw stream cannot accept more data at the moment. | | ---------------------------------------------------------------------- | Methods inherited from _IOBase: | | __del__(...) | | __enter__(...) | | __exit__(...) | | __iter__(self, /) | Implement iter(self). | | readlines(self, hint=-1, /) | 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. | | writable(self, /) | Return whether object was opened for writing. | | If False, write() will raise OSError. | | writelines(self, lines, /) | Write a list of lines to stream. | | Line separators are not added, so it is usual for each of the | lines provided to have a line separator at the end. | | ---------------------------------------------------------------------- | Data descriptors inherited from _IOBase: | | __dict__
io.BufferedWriter
Python Library Documentation: class BufferedWriter in module _io class BufferedWriter(_BufferedIOBase) | BufferedWriter(raw, buffer_size=8192) | | 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. | | Method resolution order: | BufferedWriter | _BufferedIOBase | _IOBase | builtins.object | | Methods defined here: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __reduce__(...) | Helper for pickle. | | __reduce_ex__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __sizeof__(self, /) | Size of object in memory, in bytes. | | close(self, /) | Flush and close the IO object. | | This method has no effect if the file is already closed. | | detach(self, /) | 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. | | fileno(self, /) | Return underlying file descriptor if one exists. | | Raise OSError if the IO object does not use a file descriptor. | | flush(self, /) | Flush write buffers, if applicable. | | This is not implemented for read-only and non-blocking streams. | | isatty(self, /) | Return whether this is an 'interactive' stream. | | Return False if it can't be determined. | | seek(self, target, whence=0, /) | Change the stream position to the given byte offset. | | offset | The stream position, relative to 'whence'. | whence | The relative position to seek from. | | The offset is interpreted relative to the position indicated by whence. | Values for whence are: | | * os.SEEK_SET or 0 -- start of stream (the default); offset should be zero or positive | * os.SEEK_CUR or 1 -- current stream position; offset may be negative | * os.SEEK_END or 2 -- end of stream; offset is usually negative | | Return the new absolute position. | | seekable(self, /) | Return whether object supports random access. | | If False, seek(), tell() and truncate() will raise OSError. | This method may need to do a test seek(). | | tell(self, /) | Return current stream position. | | truncate(self, pos=None, /) | Truncate file to size bytes. | | File pointer is left unchanged. Size defaults to the current IO position | as reported by tell(). Return the new size. | | writable(self, /) | Return whether object was opened for writing. | | If False, write() will raise OSError. | | write(self, buffer, /) | Write buffer b to the IO stream. | | Return the number of bytes written, which is always | the length of b in bytes. | | Raise BlockingIOError if the buffer is full and the | underlying raw stream cannot accept more data at the moment. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | closed | | mode | | name | | raw | | ---------------------------------------------------------------------- | Methods inherited from _BufferedIOBase: | | read(self, size=-1, /) | Read and return up to n bytes. | | If the size argument is omitted, None, or negative, read and | return all data until EOF. | | If the size 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). | However, 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. | | Return an empty bytes object on EOF. | | Return None if the underlying raw stream was open in non-blocking | mode and no data is available at the moment. | | read1(self, size=-1, /) | Read and return up to size bytes, with at most one read() call to the underlying raw stream. | | Return an empty bytes object on EOF. | A short result does not imply that EOF is imminent. | | readinto(self, buffer, /) | | readinto1(self, buffer, /) | | ---------------------------------------------------------------------- | Methods inherited from _IOBase: | | __del__(...) | | __enter__(...) | | __exit__(...) | | __iter__(self, /) | Implement iter(self). | | __next__(self, /) | Implement next(self). | | readable(self, /) | Return whether object was opened for reading. | | If False, read() will raise OSError. | | readline(self, size=-1, /) | Read and return a line from the stream. | | If size is specified, at most size 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(self, hint=-1, /) | 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(self, lines, /) | Write a list of lines to stream. | | Line separators are not added, so it is usual for each of the | lines provided to have a line separator at the end. | | ---------------------------------------------------------------------- | Data descriptors inherited from _IOBase: | | __dict__
io.BytesIO
Python Library Documentation: class BytesIO in module _io class BytesIO(_BufferedIOBase) | BytesIO(initial_bytes=b'') | | Buffered I/O implementation using an in-memory bytes buffer. | | Method resolution order: | BytesIO | _BufferedIOBase | _IOBase | builtins.object | | Methods defined here: | | __getstate__(...) | Helper for pickle. | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __iter__(self, /) | Implement iter(self). | | __next__(self, /) | Implement next(self). | | __setstate__(...) | | __sizeof__(...) | Size of object in memory, in bytes. | | close(self, /) | Disable all I/O operations. | | flush(self, /) | Does nothing. | | getbuffer(self, /) | Get a read-write view over the contents of the BytesIO object. | | getvalue(self, /) | Retrieve the entire contents of the BytesIO object. | | isatty(self, /) | Always returns False. | | BytesIO objects are not connected to a TTY-like device. | | read(self, size=-1, /) | Read at most size bytes, returned as a bytes object. | | If the size argument is negative, read until EOF is reached. | Return an empty bytes object at EOF. | | read1(self, size=-1, /) | Read at most size bytes, returned as a bytes object. | | If the size argument is negative or omitted, read until EOF is reached. | Return an empty bytes object at EOF. | | readable(self, /) | Returns True if the IO object can be read. | | readinto(self, buffer, /) | Read bytes into buffer. | | Returns number of bytes read (0 for EOF), or None if the object | is set not to block and has no data to read. | | readline(self, size=-1, /) | Next line from the file, as a bytes object. | | 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 bytes object at EOF. | | readlines(self, size=None, /) | List of bytes objects, 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(self, pos, whence=0, /) | 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(self, /) | Returns True if the IO object can be seeked. | | tell(self, /) | Current file position, an integer. | | truncate(self, size=None, /) | 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(self, /) | Returns True if the IO object can be written. | | write(self, b, /) | Write bytes to file. | | Return the number of bytes written. | | writelines(self, lines, /) | Write lines to the file. | | Note that newlines are not added. lines can be any iterable object | producing bytes-like objects. This is equivalent to calling write() for | each element. | | ---------------------------------------------------------------------- | Static methods defined here: | | __new__(*args, **kwargs) | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | closed | True if the file is closed. | | ---------------------------------------------------------------------- | Methods inherited from _BufferedIOBase: | | detach(self, /) | 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. | | readinto1(self, buffer, /) | | ---------------------------------------------------------------------- | Methods inherited from _IOBase: | | __del__(...) | | __enter__(...) | | __exit__(...) | | fileno(self, /) | Return underlying file descriptor if one exists. | | Raise OSError if the IO object does not use a file descriptor. | | ---------------------------------------------------------------------- | Data descriptors inherited from _IOBase: | | __dict__
io.DEFAULT_BUFFER_SIZE
Python Library Documentation: int object
class int(object)
| int([x]) -> integer
| int(x, base=10) -> integer
|
| Convert a number or string to an integer, or return 0 if no arguments
| are given. If x is a number, return x.__int__(). For floating-point
| numbers, this truncates towards zero.
|
| If x is not a number or if base is given, then x must be a string,
| bytes, or bytearray instance representing an integer literal in the
| given base. The literal can be preceded by '+' or '-' and be surrounded
| by whitespace. The base defaults to 10. Valid bases are 0 and 2-36.
| Base 0 means to interpret the base from the string as an integer literal.
| >>> int('0b100', base=0)
| 4
|
| Built-in subclasses:
| bool
|
| Methods defined here:
|
| __abs__(self, /)
| abs(self)
|
| __add__(self, value, /)
| Return self+value.
|
| __and__(self, value, /)
| Return self&value.
|
| __bool__(self, /)
| True if self else False
|
| __ceil__(...)
| Ceiling of an Integral returns itself.
|
| __divmod__(self, value, /)
| Return divmod(self, value).
|
| __eq__(self, value, /)
| Return self==value.
|
| __float__(self, /)
| float(self)
|
| __floor__(...)
| Flooring an Integral returns itself.
|
| __floordiv__(self, value, /)
| Return self//value.
|
| __format__(self, format_spec, /)
| Convert to a string according to format_spec.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getnewargs__(self, /)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __index__(self, /)
| Return self converted to an integer, if self is suitable for use as an index into a list.
|
| __int__(self, /)
| int(self)
|
| __invert__(self, /)
| ~self
|
| __le__(self, value, /)
| Return self<=value.
|
| __lshift__(self, value, /)
| Return self<<value.
|
| __lt__(self, value, /)
| Return self<value.
|
| __mod__(self, value, /)
| Return self%value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __neg__(self, /)
| -self
|
| __or__(self, value, /)
| Return self|value.
|
| __pos__(self, /)
| +self
|
| __pow__(self, value, mod=None, /)
| Return pow(self, value, mod).
|
| __radd__(self, value, /)
| Return value+self.
|
| __rand__(self, value, /)
| Return value&self.
|
| __rdivmod__(self, value, /)
| Return divmod(value, self).
|
| __repr__(self, /)
| Return repr(self).
|
| __rfloordiv__(self, value, /)
| Return value//self.
|
| __rlshift__(self, value, /)
| Return value<<self.
|
| __rmod__(self, value, /)
| Return value%self.
|
| __rmul__(self, value, /)
| Return value*self.
|
| __ror__(self, value, /)
| Return value|self.
|
| __round__(...)
| Rounding an Integral returns itself.
|
| Rounding with an ndigits argument also returns an integer.
|
| __rpow__(self, value, mod=None, /)
| Return pow(value, self, mod).
|
| __rrshift__(self, value, /)
| Return value>>self.
|
| __rshift__(self, value, /)
| Return self>>value.
|
| __rsub__(self, value, /)
| Return value-self.
|
| __rtruediv__(self, value, /)
| Return value/self.
|
| __rxor__(self, value, /)
| Return value^self.
|
| __sizeof__(self, /)
| Returns size in memory, in bytes.
|
| __sub__(self, value, /)
| Return self-value.
|
| __truediv__(self, value, /)
| Return self/value.
|
| __trunc__(...)
| Truncating an Integral returns itself.
|
| __xor__(self, value, /)
| Return self^value.
|
| as_integer_ratio(self, /)
| Return a pair of integers, whose ratio is equal to the original int.
|
| The ratio is in lowest terms and has a positive denominator.
|
| >>> (10).as_integer_ratio()
| (10, 1)
| >>> (-10).as_integer_ratio()
| (-10, 1)
| >>> (0).as_integer_ratio()
| (0, 1)
|
| bit_count(self, /)
| Number of ones in the binary representation of the absolute value of self.
|
| Also known as the population count.
|
| >>> bin(13)
| '0b1101'
| >>> (13).bit_count()
| 3
|
| bit_length(self, /)
| Number of bits necessary to represent self in binary.
|
| >>> bin(37)
| '0b100101'
| >>> (37).bit_length()
| 6
|
| conjugate(...)
| Returns self, the complex conjugate of any int.
|
| is_integer(self, /)
| Returns True. Exists for duck type compatibility with float.is_integer.
|
| to_bytes(self, /, length=1, byteorder='big', *, signed=False)
| Return an array of bytes representing an integer.
|
| length
| Length of bytes object to use. An OverflowError is raised if the
| integer is not representable with the given number of bytes. Default
| is length 1.
| byteorder
| The byte order used to represent the integer. If byteorder is 'big',
| the most significant byte is at the beginning of the byte array. If
| byteorder is 'little', the most significant byte is at the end of the
| byte array. To request the native byte order of the host system, use
| `sys.byteorder' as the byte order value. Default is to use 'big'.
| signed
| Determines whether two's complement is used to represent the integer.
| If signed is False and a negative integer is given, an OverflowError
| is raised.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| from_bytes(bytes, byteorder='big', *, signed=False)
| Return the integer represented by the given array of bytes.
|
| bytes
| Holds the array of bytes to convert. The argument must either
| support the buffer protocol or be an iterable object producing bytes.
| Bytes and bytearray are examples of built-in objects that support the
| buffer protocol.
| byteorder
| The byte order used to represent the integer. If byteorder is 'big',
| the most significant byte is at the beginning of the byte array. If
| byteorder is 'little', the most significant byte is at the end of the
| byte array. To request the native byte order of the host system, use
| `sys.byteorder' as the byte order value. Default is to use 'big'.
| signed
| Indicates whether two's complement is used to represent the integer.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| denominator
| the denominator of a rational number in lowest terms
|
| imag
| the imaginary part of a complex number
|
| numerator
| the numerator of a rational number in lowest terms
|
| real
| the real part of a complex number
io.FileIO
Python Library Documentation: class FileIO in module _io class FileIO(_RawIOBase) | FileIO(file, mode='r', closefd=True, opener=None) | | Open a file. | | The mode can be 'r' (default), 'w', 'x' or 'a' for reading, | writing, exclusive creation 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. A FileExistsError will be raised if it already | exists when opened for creating. Opening a file for creating implies | writing so this mode behaves in a similar way to 'w'.Add a '+' to the mode | to allow simultaneous reading and writing. A custom opener can be used by | passing a callable as *opener*. The underlying file descriptor for the file | object is then obtained by calling opener with (*name*, *flags*). | *opener* must return an open file descriptor (passing os.open as *opener* | results in functionality similar to passing None). | | Method resolution order: | FileIO | _RawIOBase | _IOBase | builtins.object | | Methods defined here: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __reduce__(...) | Helper for pickle. | | __reduce_ex__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | close(self, /) | Close the file. | | A closed file cannot be used for further I/O operations. close() may be | called more than once without error. | | fileno(self, /) | Return the underlying file descriptor (an integer). | | isatty(self, /) | True if the file is connected to a TTY device. | | read(self, size=-1, /) | 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. | Return an empty bytes object at EOF. | | readable(self, /) | True if file was opened in a read mode. | | readall(self, /) | 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. Return an empty bytes object at EOF. | | readinto(self, buffer, /) | Same as RawIOBase.readinto(). | | seek(self, pos, whence=0, /) | 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(self, /) | True if file supports random-access. | | tell(self, /) | Current file position. | | Can raise OSError for non seekable files. | | truncate(self, size=None, /) | 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(self, /) | True if file was opened in a write mode. | | write(self, b, /) | Write buffer b to file, return number of bytes 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. | | ---------------------------------------------------------------------- | Static methods defined here: | | __new__(*args, **kwargs) | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | 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 | | ---------------------------------------------------------------------- | Methods inherited from _IOBase: | | __del__(...) | | __enter__(...) | | __exit__(...) | | __iter__(self, /) | Implement iter(self). | | __next__(self, /) | Implement next(self). | | flush(self, /) | Flush write buffers, if applicable. | | This is not implemented for read-only and non-blocking streams. | | readline(self, size=-1, /) | Read and return a line from the stream. | | If size is specified, at most size 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(self, hint=-1, /) | 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(self, lines, /) | Write a list of lines to stream. | | Line separators are not added, so it is usual for each of the | lines provided to have a line separator at the end. | | ---------------------------------------------------------------------- | Data descriptors inherited from _IOBase: | | __dict__
io.IOBase
Python Library Documentation: class IOBase in module io
class IOBase(_io._IOBase)
| 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!')
|
| Method resolution order:
| IOBase
| _io._IOBase
| builtins.object
|
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| ----------------------------------------------------------------------
| Methods inherited from _io._IOBase:
|
| __del__(...)
|
| __enter__(...)
|
| __exit__(...)
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| close(self, /)
| Flush and close the IO object.
|
| This method has no effect if the file is already closed.
|
| fileno(self, /)
| Return underlying file descriptor if one exists.
|
| Raise OSError if the IO object does not use a file descriptor.
|
| flush(self, /)
| Flush write buffers, if applicable.
|
| This is not implemented for read-only and non-blocking streams.
|
| isatty(self, /)
| Return whether this is an 'interactive' stream.
|
| Return False if it can't be determined.
|
| readable(self, /)
| Return whether object was opened for reading.
|
| If False, read() will raise OSError.
|
| readline(self, size=-1, /)
| Read and return a line from the stream.
|
| If size is specified, at most size 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(self, hint=-1, /)
| 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(self, offset, whence=0, /)
| Change the stream position to the given byte offset.
|
| offset
| The stream position, relative to 'whence'.
| whence
| The relative position to seek from.
|
| The offset is interpreted relative to the position indicated by whence.
| Values for whence are:
|
| * os.SEEK_SET or 0 -- start of stream (the default); offset should be zero or positive
| * os.SEEK_CUR or 1 -- current stream position; offset may be negative
| * os.SEEK_END or 2 -- end of stream; offset is usually negative
|
| Return the new absolute position.
|
| seekable(self, /)
| Return whether object supports random access.
|
| If False, seek(), tell() and truncate() will raise OSError.
| This method may need to do a test seek().
|
| tell(self, /)
| Return current stream position.
|
| truncate(self, size=None, /)
| Truncate file to size bytes.
|
| File pointer is left unchanged. Size defaults to the current IO position
| as reported by tell(). Return the new size.
|
| writable(self, /)
| Return whether object was opened for writing.
|
| If False, write() will raise OSError.
|
| writelines(self, lines, /)
| Write a list of lines to stream.
|
| Line separators are not added, so it is usual for each of the
| lines provided to have a line separator at the end.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from _io._IOBase:
|
| __dict__
|
| closed
io.IncrementalNewlineDecoder
Python Library Documentation: class IncrementalNewlineDecoder in module _io class IncrementalNewlineDecoder(builtins.object) | IncrementalNewlineDecoder(decoder, translate, errors='strict') | | Codec used when reading a file in universal newlines mode. | | It wraps another incremental decoder, translating \r\n and \r into \n. | It also records the types of newlines encountered. When used with | translate=False, it ensures that the newline sequence is returned in | one piece. When used with decoder=None, it expects unicode strings as | decode input and translates newlines without first invoking an external | decoder. | | Methods defined here: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | decode(self, /, input, final=False) | | getstate(self, /) | | reset(self, /) | | setstate(self, state, /) | | ---------------------------------------------------------------------- | Data descriptors defined here: | | newlines
io.RawIOBase
Python Library Documentation: class RawIOBase in module io class RawIOBase(_io._RawIOBase, IOBase) | Base class for raw binary I/O. | | Method resolution order: | RawIOBase | _io._RawIOBase | IOBase | _io._IOBase | builtins.object | | Data and other attributes defined here: | | __abstractmethods__ = frozenset() | | ---------------------------------------------------------------------- | Methods inherited from _io._RawIOBase: | | read(self, size=-1, /) | | readall(self, /) | Read until EOF, using multiple read() call. | | readinto(...) | | write(...) | | ---------------------------------------------------------------------- | Methods inherited from _io._IOBase: | | __del__(...) | | __enter__(...) | | __exit__(...) | | __iter__(self, /) | Implement iter(self). | | __next__(self, /) | Implement next(self). | | close(self, /) | Flush and close the IO object. | | This method has no effect if the file is already closed. | | fileno(self, /) | Return underlying file descriptor if one exists. | | Raise OSError if the IO object does not use a file descriptor. | | flush(self, /) | Flush write buffers, if applicable. | | This is not implemented for read-only and non-blocking streams. | | isatty(self, /) | Return whether this is an 'interactive' stream. | | Return False if it can't be determined. | | readable(self, /) | Return whether object was opened for reading. | | If False, read() will raise OSError. | | readline(self, size=-1, /) | Read and return a line from the stream. | | If size is specified, at most size 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(self, hint=-1, /) | 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(self, offset, whence=0, /) | Change the stream position to the given byte offset. | | offset | The stream position, relative to 'whence'. | whence | The relative position to seek from. | | The offset is interpreted relative to the position indicated by whence. | Values for whence are: | | * os.SEEK_SET or 0 -- start of stream (the default); offset should be zero or positive | * os.SEEK_CUR or 1 -- current stream position; offset may be negative | * os.SEEK_END or 2 -- end of stream; offset is usually negative | | Return the new absolute position. | | seekable(self, /) | Return whether object supports random access. | | If False, seek(), tell() and truncate() will raise OSError. | This method may need to do a test seek(). | | tell(self, /) | Return current stream position. | | truncate(self, size=None, /) | Truncate file to size bytes. | | File pointer is left unchanged. Size defaults to the current IO position | as reported by tell(). Return the new size. | | writable(self, /) | Return whether object was opened for writing. | | If False, write() will raise OSError. | | writelines(self, lines, /) | Write a list of lines to stream. | | Line separators are not added, so it is usual for each of the | lines provided to have a line separator at the end. | | ---------------------------------------------------------------------- | Data descriptors inherited from _io._IOBase: | | __dict__ | | closed
io.SEEK_CUR
Python Library Documentation: int object
class int(object)
| int([x]) -> integer
| int(x, base=10) -> integer
|
| Convert a number or string to an integer, or return 0 if no arguments
| are given. If x is a number, return x.__int__(). For floating-point
| numbers, this truncates towards zero.
|
| If x is not a number or if base is given, then x must be a string,
| bytes, or bytearray instance representing an integer literal in the
| given base. The literal can be preceded by '+' or '-' and be surrounded
| by whitespace. The base defaults to 10. Valid bases are 0 and 2-36.
| Base 0 means to interpret the base from the string as an integer literal.
| >>> int('0b100', base=0)
| 4
|
| Built-in subclasses:
| bool
|
| Methods defined here:
|
| __abs__(self, /)
| abs(self)
|
| __add__(self, value, /)
| Return self+value.
|
| __and__(self, value, /)
| Return self&value.
|
| __bool__(self, /)
| True if self else False
|
| __ceil__(...)
| Ceiling of an Integral returns itself.
|
| __divmod__(self, value, /)
| Return divmod(self, value).
|
| __eq__(self, value, /)
| Return self==value.
|
| __float__(self, /)
| float(self)
|
| __floor__(...)
| Flooring an Integral returns itself.
|
| __floordiv__(self, value, /)
| Return self//value.
|
| __format__(self, format_spec, /)
| Convert to a string according to format_spec.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getnewargs__(self, /)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __index__(self, /)
| Return self converted to an integer, if self is suitable for use as an index into a list.
|
| __int__(self, /)
| int(self)
|
| __invert__(self, /)
| ~self
|
| __le__(self, value, /)
| Return self<=value.
|
| __lshift__(self, value, /)
| Return self<<value.
|
| __lt__(self, value, /)
| Return self<value.
|
| __mod__(self, value, /)
| Return self%value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __neg__(self, /)
| -self
|
| __or__(self, value, /)
| Return self|value.
|
| __pos__(self, /)
| +self
|
| __pow__(self, value, mod=None, /)
| Return pow(self, value, mod).
|
| __radd__(self, value, /)
| Return value+self.
|
| __rand__(self, value, /)
| Return value&self.
|
| __rdivmod__(self, value, /)
| Return divmod(value, self).
|
| __repr__(self, /)
| Return repr(self).
|
| __rfloordiv__(self, value, /)
| Return value//self.
|
| __rlshift__(self, value, /)
| Return value<<self.
|
| __rmod__(self, value, /)
| Return value%self.
|
| __rmul__(self, value, /)
| Return value*self.
|
| __ror__(self, value, /)
| Return value|self.
|
| __round__(...)
| Rounding an Integral returns itself.
|
| Rounding with an ndigits argument also returns an integer.
|
| __rpow__(self, value, mod=None, /)
| Return pow(value, self, mod).
|
| __rrshift__(self, value, /)
| Return value>>self.
|
| __rshift__(self, value, /)
| Return self>>value.
|
| __rsub__(self, value, /)
| Return value-self.
|
| __rtruediv__(self, value, /)
| Return value/self.
|
| __rxor__(self, value, /)
| Return value^self.
|
| __sizeof__(self, /)
| Returns size in memory, in bytes.
|
| __sub__(self, value, /)
| Return self-value.
|
| __truediv__(self, value, /)
| Return self/value.
|
| __trunc__(...)
| Truncating an Integral returns itself.
|
| __xor__(self, value, /)
| Return self^value.
|
| as_integer_ratio(self, /)
| Return a pair of integers, whose ratio is equal to the original int.
|
| The ratio is in lowest terms and has a positive denominator.
|
| >>> (10).as_integer_ratio()
| (10, 1)
| >>> (-10).as_integer_ratio()
| (-10, 1)
| >>> (0).as_integer_ratio()
| (0, 1)
|
| bit_count(self, /)
| Number of ones in the binary representation of the absolute value of self.
|
| Also known as the population count.
|
| >>> bin(13)
| '0b1101'
| >>> (13).bit_count()
| 3
|
| bit_length(self, /)
| Number of bits necessary to represent self in binary.
|
| >>> bin(37)
| '0b100101'
| >>> (37).bit_length()
| 6
|
| conjugate(...)
| Returns self, the complex conjugate of any int.
|
| is_integer(self, /)
| Returns True. Exists for duck type compatibility with float.is_integer.
|
| to_bytes(self, /, length=1, byteorder='big', *, signed=False)
| Return an array of bytes representing an integer.
|
| length
| Length of bytes object to use. An OverflowError is raised if the
| integer is not representable with the given number of bytes. Default
| is length 1.
| byteorder
| The byte order used to represent the integer. If byteorder is 'big',
| the most significant byte is at the beginning of the byte array. If
| byteorder is 'little', the most significant byte is at the end of the
| byte array. To request the native byte order of the host system, use
| `sys.byteorder' as the byte order value. Default is to use 'big'.
| signed
| Determines whether two's complement is used to represent the integer.
| If signed is False and a negative integer is given, an OverflowError
| is raised.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| from_bytes(bytes, byteorder='big', *, signed=False)
| Return the integer represented by the given array of bytes.
|
| bytes
| Holds the array of bytes to convert. The argument must either
| support the buffer protocol or be an iterable object producing bytes.
| Bytes and bytearray are examples of built-in objects that support the
| buffer protocol.
| byteorder
| The byte order used to represent the integer. If byteorder is 'big',
| the most significant byte is at the beginning of the byte array. If
| byteorder is 'little', the most significant byte is at the end of the
| byte array. To request the native byte order of the host system, use
| `sys.byteorder' as the byte order value. Default is to use 'big'.
| signed
| Indicates whether two's complement is used to represent the integer.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| denominator
| the denominator of a rational number in lowest terms
|
| imag
| the imaginary part of a complex number
|
| numerator
| the numerator of a rational number in lowest terms
|
| real
| the real part of a complex number
io.SEEK_END
Python Library Documentation: int object
class int(object)
| int([x]) -> integer
| int(x, base=10) -> integer
|
| Convert a number or string to an integer, or return 0 if no arguments
| are given. If x is a number, return x.__int__(). For floating-point
| numbers, this truncates towards zero.
|
| If x is not a number or if base is given, then x must be a string,
| bytes, or bytearray instance representing an integer literal in the
| given base. The literal can be preceded by '+' or '-' and be surrounded
| by whitespace. The base defaults to 10. Valid bases are 0 and 2-36.
| Base 0 means to interpret the base from the string as an integer literal.
| >>> int('0b100', base=0)
| 4
|
| Built-in subclasses:
| bool
|
| Methods defined here:
|
| __abs__(self, /)
| abs(self)
|
| __add__(self, value, /)
| Return self+value.
|
| __and__(self, value, /)
| Return self&value.
|
| __bool__(self, /)
| True if self else False
|
| __ceil__(...)
| Ceiling of an Integral returns itself.
|
| __divmod__(self, value, /)
| Return divmod(self, value).
|
| __eq__(self, value, /)
| Return self==value.
|
| __float__(self, /)
| float(self)
|
| __floor__(...)
| Flooring an Integral returns itself.
|
| __floordiv__(self, value, /)
| Return self//value.
|
| __format__(self, format_spec, /)
| Convert to a string according to format_spec.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getnewargs__(self, /)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __index__(self, /)
| Return self converted to an integer, if self is suitable for use as an index into a list.
|
| __int__(self, /)
| int(self)
|
| __invert__(self, /)
| ~self
|
| __le__(self, value, /)
| Return self<=value.
|
| __lshift__(self, value, /)
| Return self<<value.
|
| __lt__(self, value, /)
| Return self<value.
|
| __mod__(self, value, /)
| Return self%value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __neg__(self, /)
| -self
|
| __or__(self, value, /)
| Return self|value.
|
| __pos__(self, /)
| +self
|
| __pow__(self, value, mod=None, /)
| Return pow(self, value, mod).
|
| __radd__(self, value, /)
| Return value+self.
|
| __rand__(self, value, /)
| Return value&self.
|
| __rdivmod__(self, value, /)
| Return divmod(value, self).
|
| __repr__(self, /)
| Return repr(self).
|
| __rfloordiv__(self, value, /)
| Return value//self.
|
| __rlshift__(self, value, /)
| Return value<<self.
|
| __rmod__(self, value, /)
| Return value%self.
|
| __rmul__(self, value, /)
| Return value*self.
|
| __ror__(self, value, /)
| Return value|self.
|
| __round__(...)
| Rounding an Integral returns itself.
|
| Rounding with an ndigits argument also returns an integer.
|
| __rpow__(self, value, mod=None, /)
| Return pow(value, self, mod).
|
| __rrshift__(self, value, /)
| Return value>>self.
|
| __rshift__(self, value, /)
| Return self>>value.
|
| __rsub__(self, value, /)
| Return value-self.
|
| __rtruediv__(self, value, /)
| Return value/self.
|
| __rxor__(self, value, /)
| Return value^self.
|
| __sizeof__(self, /)
| Returns size in memory, in bytes.
|
| __sub__(self, value, /)
| Return self-value.
|
| __truediv__(self, value, /)
| Return self/value.
|
| __trunc__(...)
| Truncating an Integral returns itself.
|
| __xor__(self, value, /)
| Return self^value.
|
| as_integer_ratio(self, /)
| Return a pair of integers, whose ratio is equal to the original int.
|
| The ratio is in lowest terms and has a positive denominator.
|
| >>> (10).as_integer_ratio()
| (10, 1)
| >>> (-10).as_integer_ratio()
| (-10, 1)
| >>> (0).as_integer_ratio()
| (0, 1)
|
| bit_count(self, /)
| Number of ones in the binary representation of the absolute value of self.
|
| Also known as the population count.
|
| >>> bin(13)
| '0b1101'
| >>> (13).bit_count()
| 3
|
| bit_length(self, /)
| Number of bits necessary to represent self in binary.
|
| >>> bin(37)
| '0b100101'
| >>> (37).bit_length()
| 6
|
| conjugate(...)
| Returns self, the complex conjugate of any int.
|
| is_integer(self, /)
| Returns True. Exists for duck type compatibility with float.is_integer.
|
| to_bytes(self, /, length=1, byteorder='big', *, signed=False)
| Return an array of bytes representing an integer.
|
| length
| Length of bytes object to use. An OverflowError is raised if the
| integer is not representable with the given number of bytes. Default
| is length 1.
| byteorder
| The byte order used to represent the integer. If byteorder is 'big',
| the most significant byte is at the beginning of the byte array. If
| byteorder is 'little', the most significant byte is at the end of the
| byte array. To request the native byte order of the host system, use
| `sys.byteorder' as the byte order value. Default is to use 'big'.
| signed
| Determines whether two's complement is used to represent the integer.
| If signed is False and a negative integer is given, an OverflowError
| is raised.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| from_bytes(bytes, byteorder='big', *, signed=False)
| Return the integer represented by the given array of bytes.
|
| bytes
| Holds the array of bytes to convert. The argument must either
| support the buffer protocol or be an iterable object producing bytes.
| Bytes and bytearray are examples of built-in objects that support the
| buffer protocol.
| byteorder
| The byte order used to represent the integer. If byteorder is 'big',
| the most significant byte is at the beginning of the byte array. If
| byteorder is 'little', the most significant byte is at the end of the
| byte array. To request the native byte order of the host system, use
| `sys.byteorder' as the byte order value. Default is to use 'big'.
| signed
| Indicates whether two's complement is used to represent the integer.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| denominator
| the denominator of a rational number in lowest terms
|
| imag
| the imaginary part of a complex number
|
| numerator
| the numerator of a rational number in lowest terms
|
| real
| the real part of a complex number
io.SEEK_SET
Python Library Documentation: int object
class int(object)
| int([x]) -> integer
| int(x, base=10) -> integer
|
| Convert a number or string to an integer, or return 0 if no arguments
| are given. If x is a number, return x.__int__(). For floating-point
| numbers, this truncates towards zero.
|
| If x is not a number or if base is given, then x must be a string,
| bytes, or bytearray instance representing an integer literal in the
| given base. The literal can be preceded by '+' or '-' and be surrounded
| by whitespace. The base defaults to 10. Valid bases are 0 and 2-36.
| Base 0 means to interpret the base from the string as an integer literal.
| >>> int('0b100', base=0)
| 4
|
| Built-in subclasses:
| bool
|
| Methods defined here:
|
| __abs__(self, /)
| abs(self)
|
| __add__(self, value, /)
| Return self+value.
|
| __and__(self, value, /)
| Return self&value.
|
| __bool__(self, /)
| True if self else False
|
| __ceil__(...)
| Ceiling of an Integral returns itself.
|
| __divmod__(self, value, /)
| Return divmod(self, value).
|
| __eq__(self, value, /)
| Return self==value.
|
| __float__(self, /)
| float(self)
|
| __floor__(...)
| Flooring an Integral returns itself.
|
| __floordiv__(self, value, /)
| Return self//value.
|
| __format__(self, format_spec, /)
| Convert to a string according to format_spec.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getnewargs__(self, /)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __index__(self, /)
| Return self converted to an integer, if self is suitable for use as an index into a list.
|
| __int__(self, /)
| int(self)
|
| __invert__(self, /)
| ~self
|
| __le__(self, value, /)
| Return self<=value.
|
| __lshift__(self, value, /)
| Return self<<value.
|
| __lt__(self, value, /)
| Return self<value.
|
| __mod__(self, value, /)
| Return self%value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __neg__(self, /)
| -self
|
| __or__(self, value, /)
| Return self|value.
|
| __pos__(self, /)
| +self
|
| __pow__(self, value, mod=None, /)
| Return pow(self, value, mod).
|
| __radd__(self, value, /)
| Return value+self.
|
| __rand__(self, value, /)
| Return value&self.
|
| __rdivmod__(self, value, /)
| Return divmod(value, self).
|
| __repr__(self, /)
| Return repr(self).
|
| __rfloordiv__(self, value, /)
| Return value//self.
|
| __rlshift__(self, value, /)
| Return value<<self.
|
| __rmod__(self, value, /)
| Return value%self.
|
| __rmul__(self, value, /)
| Return value*self.
|
| __ror__(self, value, /)
| Return value|self.
|
| __round__(...)
| Rounding an Integral returns itself.
|
| Rounding with an ndigits argument also returns an integer.
|
| __rpow__(self, value, mod=None, /)
| Return pow(value, self, mod).
|
| __rrshift__(self, value, /)
| Return value>>self.
|
| __rshift__(self, value, /)
| Return self>>value.
|
| __rsub__(self, value, /)
| Return value-self.
|
| __rtruediv__(self, value, /)
| Return value/self.
|
| __rxor__(self, value, /)
| Return value^self.
|
| __sizeof__(self, /)
| Returns size in memory, in bytes.
|
| __sub__(self, value, /)
| Return self-value.
|
| __truediv__(self, value, /)
| Return self/value.
|
| __trunc__(...)
| Truncating an Integral returns itself.
|
| __xor__(self, value, /)
| Return self^value.
|
| as_integer_ratio(self, /)
| Return a pair of integers, whose ratio is equal to the original int.
|
| The ratio is in lowest terms and has a positive denominator.
|
| >>> (10).as_integer_ratio()
| (10, 1)
| >>> (-10).as_integer_ratio()
| (-10, 1)
| >>> (0).as_integer_ratio()
| (0, 1)
|
| bit_count(self, /)
| Number of ones in the binary representation of the absolute value of self.
|
| Also known as the population count.
|
| >>> bin(13)
| '0b1101'
| >>> (13).bit_count()
| 3
|
| bit_length(self, /)
| Number of bits necessary to represent self in binary.
|
| >>> bin(37)
| '0b100101'
| >>> (37).bit_length()
| 6
|
| conjugate(...)
| Returns self, the complex conjugate of any int.
|
| is_integer(self, /)
| Returns True. Exists for duck type compatibility with float.is_integer.
|
| to_bytes(self, /, length=1, byteorder='big', *, signed=False)
| Return an array of bytes representing an integer.
|
| length
| Length of bytes object to use. An OverflowError is raised if the
| integer is not representable with the given number of bytes. Default
| is length 1.
| byteorder
| The byte order used to represent the integer. If byteorder is 'big',
| the most significant byte is at the beginning of the byte array. If
| byteorder is 'little', the most significant byte is at the end of the
| byte array. To request the native byte order of the host system, use
| `sys.byteorder' as the byte order value. Default is to use 'big'.
| signed
| Determines whether two's complement is used to represent the integer.
| If signed is False and a negative integer is given, an OverflowError
| is raised.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| from_bytes(bytes, byteorder='big', *, signed=False)
| Return the integer represented by the given array of bytes.
|
| bytes
| Holds the array of bytes to convert. The argument must either
| support the buffer protocol or be an iterable object producing bytes.
| Bytes and bytearray are examples of built-in objects that support the
| buffer protocol.
| byteorder
| The byte order used to represent the integer. If byteorder is 'big',
| the most significant byte is at the beginning of the byte array. If
| byteorder is 'little', the most significant byte is at the end of the
| byte array. To request the native byte order of the host system, use
| `sys.byteorder' as the byte order value. Default is to use 'big'.
| signed
| Indicates whether two's complement is used to represent the integer.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| denominator
| the denominator of a rational number in lowest terms
|
| imag
| the imaginary part of a complex number
|
| numerator
| the numerator of a rational number in lowest terms
|
| real
| the real part of a complex number
io.StringIO
Python Library Documentation: class StringIO in module _io class StringIO(_TextIOBase) | StringIO(initial_value='', newline='\n') | | 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 | builtins.object | | Methods defined here: | | __getstate__(...) | Helper for pickle. | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __next__(self, /) | Implement next(self). | | __setstate__(...) | | close(self, /) | 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(self, /) | Retrieve the entire contents of the object. | | read(self, size=-1, /) | Read at most size characters, returned as a string. | | If the argument is negative or omitted, read until EOF | is reached. Return an empty string at EOF. | | readable(self, /) | Returns True if the IO object can be read. | | readline(self, size=-1, /) | Read until newline or EOF. | | Returns an empty string if EOF is hit immediately. | | seek(self, pos, whence=0, /) | 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(self, /) | Returns True if the IO object can be seeked. | | tell(self, /) | Tell the current file position. | | truncate(self, pos=None, /) | 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(self, /) | Returns True if the IO object can be written. | | write(self, s, /) | Write string to file. | | Returns the number of characters written, which is always equal to | the length of the string. | | ---------------------------------------------------------------------- | Static methods defined here: | | __new__(*args, **kwargs) | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | closed | | line_buffering | | newlines | Line endings translated so far. | | Only line endings translated during reading are considered. | | Subclasses should override. | | ---------------------------------------------------------------------- | Methods inherited from _TextIOBase: | | detach(self, /) | 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: | | __del__(...) | | __enter__(...) | | __exit__(...) | | __iter__(self, /) | Implement iter(self). | | fileno(self, /) | Return underlying file descriptor if one exists. | | Raise OSError if the IO object does not use a file descriptor. | | flush(self, /) | Flush write buffers, if applicable. | | This is not implemented for read-only and non-blocking streams. | | isatty(self, /) | Return whether this is an 'interactive' stream. | | Return False if it can't be determined. | | readlines(self, hint=-1, /) | 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(self, lines, /) | Write a list of lines to stream. | | Line separators are not added, so it is usual for each of the | lines provided to have a line separator at the end. | | ---------------------------------------------------------------------- | Data descriptors inherited from _IOBase: | | __dict__
io.TextIOBase
Python Library Documentation: class TextIOBase in module io 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. | | Method resolution order: | TextIOBase | _io._TextIOBase | IOBase | _io._IOBase | builtins.object | | Data and other attributes defined here: | | __abstractmethods__ = frozenset() | | ---------------------------------------------------------------------- | Methods inherited from _io._TextIOBase: | | detach(self, /) | 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(self, size=-1, /) | Read at most size characters from stream. | | Read from underlying buffer until we have size characters or we hit EOF. | If size is negative or omitted, read until EOF. | | readline(self, size=-1, /) | Read until newline or EOF. | | Return an empty string if EOF is hit immediately. | If size is specified, at most size characters will be read. | | write(self, s, /) | Write string s to stream. | | Return 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. | | ---------------------------------------------------------------------- | Methods inherited from _io._IOBase: | | __del__(...) | | __enter__(...) | | __exit__(...) | | __iter__(self, /) | Implement iter(self). | | __next__(self, /) | Implement next(self). | | close(self, /) | Flush and close the IO object. | | This method has no effect if the file is already closed. | | fileno(self, /) | Return underlying file descriptor if one exists. | | Raise OSError if the IO object does not use a file descriptor. | | flush(self, /) | Flush write buffers, if applicable. | | This is not implemented for read-only and non-blocking streams. | | isatty(self, /) | Return whether this is an 'interactive' stream. | | Return False if it can't be determined. | | readable(self, /) | Return whether object was opened for reading. | | If False, read() will raise OSError. | | readlines(self, hint=-1, /) | 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(self, offset, whence=0, /) | Change the stream position to the given byte offset. | | offset | The stream position, relative to 'whence'. | whence | The relative position to seek from. | | The offset is interpreted relative to the position indicated by whence. | Values for whence are: | | * os.SEEK_SET or 0 -- start of stream (the default); offset should be zero or positive | * os.SEEK_CUR or 1 -- current stream position; offset may be negative | * os.SEEK_END or 2 -- end of stream; offset is usually negative | | Return the new absolute position. | | seekable(self, /) | Return whether object supports random access. | | If False, seek(), tell() and truncate() will raise OSError. | This method may need to do a test seek(). | | tell(self, /) | Return current stream position. | | truncate(self, size=None, /) | Truncate file to size bytes. | | File pointer is left unchanged. Size defaults to the current IO position | as reported by tell(). Return the new size. | | writable(self, /) | Return whether object was opened for writing. | | If False, write() will raise OSError. | | writelines(self, lines, /) | Write a list of lines to stream. | | Line separators are not added, so it is usual for each of the | lines provided to have a line separator at the end. | | ---------------------------------------------------------------------- | Data descriptors inherited from _io._IOBase: | | __dict__ | | closed
io.TextIOWrapper
Python Library Documentation: class TextIOWrapper in module _io class TextIOWrapper(_TextIOBase) | TextIOWrapper(buffer, encoding=None, errors=None, newline=None, line_buffering=False, write_through=False) | | 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.getencoding(). | | errors determines the strictness of encoding and decoding (see | help(codecs.Codec) or the documentation for 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 '' or '\n', 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 | builtins.object | | Methods defined here: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __next__(self, /) | Implement next(self). | | __reduce__(...) | Helper for pickle. | | __reduce_ex__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | close(self, /) | Flush and close the IO object. | | This method has no effect if the file is already closed. | | detach(self, /) | Separate the underlying buffer from the TextIOBase and return it. | | After the underlying buffer has been detached, the TextIO is in an unusable state. | | fileno(self, /) | Return underlying file descriptor if one exists. | | Raise OSError if the IO object does not use a file descriptor. | | flush(self, /) | Flush write buffers, if applicable. | | This is not implemented for read-only and non-blocking streams. | | isatty(self, /) | Return whether this is an 'interactive' stream. | | Return False if it can't be determined. | | read(self, size=-1, /) | Read at most size characters from stream. | | Read from underlying buffer until we have size characters or we hit EOF. | If size is negative or omitted, read until EOF. | | readable(self, /) | Return whether object was opened for reading. | | If False, read() will raise OSError. | | readline(self, size=-1, /) | Read until newline or EOF. | | Return an empty string if EOF is hit immediately. | If size is specified, at most size characters will be read. | | reconfigure(self, /, *, encoding=None, errors=None, newline=None, line_buffering=None, write_through=None) | Reconfigure the text stream with new parameters. | | This also does an implicit stream flush. | | seek(self, cookie, whence=0, /) | Set the stream position, and return the new stream position. | | cookie | Zero or an opaque number returned by tell(). | whence | The relative position to seek from. | | Four operations are supported, given by the following argument | combinations: | | - seek(0, SEEK_SET): Rewind to the start of the stream. | - seek(cookie, SEEK_SET): Restore a previous position; | 'cookie' must be a number returned by tell(). | - seek(0, SEEK_END): Fast-forward to the end of the stream. | - seek(0, SEEK_CUR): Leave the current stream position unchanged. | | Any other argument combinations are invalid, | and may raise exceptions. | | seekable(self, /) | Return whether object supports random access. | | If False, seek(), tell() and truncate() will raise OSError. | This method may need to do a test seek(). | | tell(self, /) | Return the stream position as an opaque number. | | The return value of tell() can be given as input to seek(), to restore a | previous stream position. | | truncate(self, pos=None, /) | Truncate file to size bytes. | | File pointer is left unchanged. Size defaults to the current IO position | as reported by tell(). Return the new size. | | writable(self, /) | Return whether object was opened for writing. | | If False, write() will raise OSError. | | write(self, text, /) | Write string s to stream. | | Return the number of characters written | (which is always equal to the length of the string). | | ---------------------------------------------------------------------- | Data descriptors defined here: | | buffer | | closed | | encoding | Encoding of the text stream. | | Subclasses should override. | | errors | The error setting of the decoder or encoder. | | Subclasses should override. | | line_buffering | | name | | newlines | Line endings translated so far. | | Only line endings translated during reading are considered. | | Subclasses should override. | | write_through | | ---------------------------------------------------------------------- | Methods inherited from _IOBase: | | __del__(...) | | __enter__(...) | | __exit__(...) | | __iter__(self, /) | Implement iter(self). | | readlines(self, hint=-1, /) | 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(self, lines, /) | Write a list of lines to stream. | | Line separators are not added, so it is usual for each of the | lines provided to have a line separator at the end. | | ---------------------------------------------------------------------- | Data descriptors inherited from _IOBase: | | __dict__
io.UnsupportedOperation
Python Library Documentation: class UnsupportedOperation in module io class UnsupportedOperation(builtins.OSError, builtins.ValueError) | Method resolution order: | UnsupportedOperation | builtins.OSError | builtins.ValueError | builtins.Exception | builtins.BaseException | builtins.object | | Data descriptors defined here: | | __weakref__ | list of weak references to the object | | ---------------------------------------------------------------------- | Methods inherited from builtins.OSError: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __reduce__(...) | Helper for pickle. | | __str__(self, /) | Return str(self). | | ---------------------------------------------------------------------- | Static methods inherited from builtins.OSError: | | __new__(*args, **kwargs) class method of builtins.OSError | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.OSError: | | characters_written | | errno | POSIX exception code | | filename | exception filename | | filename2 | second exception filename | | strerror | exception strerror | | winerror | Win32 exception code | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
io.abc
Python Library Documentation: module abc
NAME
abc - Abstract Base Classes (ABCs) according to PEP 3119.
MODULE REFERENCE
https://docs.python.org/3.12/library/abc.html
The following documentation is automatically generated from the Python
source files. It may be incomplete, incorrect or include features that
are considered implementation detail and may vary between Python
implementations. When in doubt, consult the module reference at the
location listed above.
CLASSES
builtins.classmethod(builtins.object)
abstractclassmethod
builtins.object
ABC
builtins.property(builtins.object)
abstractproperty
builtins.staticmethod(builtins.object)
abstractstaticmethod
builtins.type(builtins.object)
ABCMeta
class ABC(builtins.object)
| Helper class that provides a standard way to create an ABC using
| inheritance.
|
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
class ABCMeta(builtins.type)
| ABCMeta(name, bases, namespace, /, **kwargs)
|
| 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()).
|
| Method resolution order:
| ABCMeta
| builtins.type
| builtins.object
|
| Methods defined here:
|
| __instancecheck__(cls, instance)
| Override for isinstance(instance, cls).
|
| __subclasscheck__(cls, subclass)
| Override for issubclass(subclass, cls).
|
| register(cls, subclass)
| Register a virtual subclass of an ABC.
|
| Returns the subclass, to allow usage as a class decorator.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(mcls, name, bases, namespace, /, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {}
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.type:
|
| __call__(self, /, *args, **kwargs)
| Call self as a function.
|
| __delattr__(self, name, /)
| Implement delattr(self, name).
|
| __dir__(self, /)
| Specialized __dir__ implementation for types.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __or__(self, value, /)
| Return self|value.
|
| __repr__(self, /)
| Return repr(self).
|
| __ror__(self, value, /)
| Return value|self.
|
| __setattr__(self, name, value, /)
| Implement setattr(self, name, value).
|
| __sizeof__(self, /)
| Return memory consumption of the type object.
|
| __subclasses__(self, /)
| Return a list of immediate subclasses.
|
| mro(self, /)
| Return a type's method resolution order.
|
| ----------------------------------------------------------------------
| Class methods inherited from builtins.type:
|
| __prepare__(...)
| __prepare__() -> dict
| used to create the namespace for the class statement
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.type:
|
| __abstractmethods__
|
| __dict__
|
| __text_signature__
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from builtins.type:
|
| __base__ = <class 'type'>
| type(object) -> the object's type
| type(name, bases, dict, **kwds) -> a new type
|
|
| __bases__ = (<class 'type'>,)
|
| __basicsize__ = 920
|
| __dictoffset__ = 264
|
| __flags__ = 2156420608
|
| __itemsize__ = 40
|
| __mro__ = (<class 'abc.ABCMeta'>, <class 'type'>, <class 'object'>)
|
| __type_params__ = ()
|
| __weakrefoffset__ = 368
class abstractclassmethod(builtins.classmethod)
| abstractclassmethod(callable)
|
| A decorator indicating abstract classmethods.
|
| Deprecated, use 'classmethod' with 'abstractmethod' instead:
|
| class C(ABC):
| @classmethod
| @abstractmethod
| def my_abstract_classmethod(cls, ...):
| ...
|
| Method resolution order:
| abstractclassmethod
| builtins.classmethod
| builtins.object
|
| Methods defined here:
|
| __init__(self, callable)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __isabstractmethod__ = True
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.classmethod:
|
| __get__(self, instance, owner=None, /)
| Return an attribute of instance, which is of type owner.
|
| __repr__(self, /)
| Return repr(self).
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.classmethod:
|
| __new__(*args, **kwargs) class method of builtins.classmethod
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.classmethod:
|
| __dict__
|
| __func__
|
| __wrapped__
class abstractproperty(builtins.property)
| abstractproperty(fget=None, fset=None, fdel=None, doc=None)
|
| A decorator indicating abstract properties.
|
| Deprecated, use 'property' with 'abstractmethod' instead:
|
| class C(ABC):
| @property
| @abstractmethod
| def my_abstract_property(self):
| ...
|
| Method resolution order:
| abstractproperty
| builtins.property
| builtins.object
|
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __isabstractmethod__ = True
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.property:
|
| __delete__(self, instance, /)
| Delete an attribute of instance.
|
| __get__(self, instance, owner=None, /)
| Return an attribute of instance, which is of type owner.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __set__(self, instance, value, /)
| Set an attribute of instance to value.
|
| __set_name__(...)
| Method to set name of a property.
|
| deleter(...)
| Descriptor to obtain a copy of the property with a different deleter.
|
| getter(...)
| Descriptor to obtain a copy of the property with a different getter.
|
| setter(...)
| Descriptor to obtain a copy of the property with a different setter.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.property:
|
| __new__(*args, **kwargs) class method of builtins.property
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.property:
|
| fdel
|
| fget
|
| fset
class abstractstaticmethod(builtins.staticmethod)
| abstractstaticmethod(callable)
|
| A decorator indicating abstract staticmethods.
|
| Deprecated, use 'staticmethod' with 'abstractmethod' instead:
|
| class C(ABC):
| @staticmethod
| @abstractmethod
| def my_abstract_staticmethod(...):
| ...
|
| Method resolution order:
| abstractstaticmethod
| builtins.staticmethod
| builtins.object
|
| Methods defined here:
|
| __init__(self, callable)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __isabstractmethod__ = True
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.staticmethod:
|
| __call__(self, /, *args, **kwargs)
| Call self as a function.
|
| __get__(self, instance, owner=None, /)
| Return an attribute of instance, which is of type owner.
|
| __repr__(self, /)
| Return repr(self).
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.staticmethod:
|
| __new__(*args, **kwargs) class method of builtins.staticmethod
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.staticmethod:
|
| __dict__
|
| __func__
|
| __wrapped__
FUNCTIONS
abstractmethod(funcobj)
A decorator indicating abstract methods.
Requires that the metaclass is ABCMeta or derived from it. A
class that has a metaclass derived from ABCMeta cannot be
instantiated unless all of its abstract methods are overridden.
The abstract methods can be called using any of the normal
'super' call mechanisms. abstractmethod() may be used to declare
abstract methods for properties and descriptors.
Usage:
class C(metaclass=ABCMeta):
@abstractmethod
def my_abstract_method(self, arg1, arg2, argN):
...
get_cache_token()
Returns the current ABC cache token.
The token is an opaque object (supporting equality testing) identifying the
current version of the ABC cache for virtual subclasses. The token changes
with every call to register() on any ABC.
update_abstractmethods(cls)
Recalculate the set of abstract methods of an abstract class.
If a class has had one of its abstract methods implemented after the
class was created, the method will not be considered implemented until
this function is called. Alternatively, if a new abstract method has been
added to the class, it will only be considered an abstract method of the
class after this function is called.
This function should be called before any use is made of the class,
usually in class decorators that add methods to the subject class.
Returns cls, to allow usage as a class decorator.
If cls is not an instance of ABCMeta, does nothing.
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\abc.py
io.open
Python Library Documentation: built-in function open in module _io
open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
Open file and return a stream. Raise OSError upon failure.
file is either a text or byte string giving the name (and the path
if the file isn't in the current working directory) of the file to
be opened or an integer file descriptor of the file to be
wrapped. (If a file descriptor is given, it is closed when the
returned I/O object is closed, unless closefd is set to False.)
mode is an optional string that specifies the mode in which the file
is opened. It defaults to 'r' which means open for reading in text
mode. Other common values are 'w' for writing (truncating the file if
it already exists), 'x' for creating and writing to a new file, and
'a' for appending (which on some Unix systems, means that all writes
append to the end of the file regardless of the current seek position).
In text mode, if encoding is not specified the encoding used is platform
dependent: locale.getencoding() is called to get the current locale encoding.
(For reading and writing raw bytes use binary mode and leave encoding
unspecified.) The available modes are:
========= ===============================================================
Character Meaning
--------- ---------------------------------------------------------------
'r' open for reading (default)
'w' open for writing, truncating the file first
'x' create a new file and open it for writing
'a' open for writing, appending to the end of the file if it exists
'b' binary mode
't' text mode (default)
'+' open a disk file for updating (reading and writing)
========= ===============================================================
The default mode is 'rt' (open for reading text). For binary random
access, the mode 'w+b' opens and truncates the file to 0 bytes, while
'r+b' opens the file without truncation. The 'x' mode implies 'w' and
raises an `FileExistsError` if the file already exists.
Python distinguishes between files opened in binary and text modes,
even when the underlying operating system doesn't. Files opened in
binary mode (appending 'b' to the mode argument) return contents as
bytes objects without any decoding. In text mode (the default, or when
't' is appended to the mode argument), the contents of the file are
returned as strings, the bytes having been first decoded using a
platform-dependent encoding or using the specified encoding if given.
buffering is an optional integer used to set the buffering policy.
Pass 0 to switch buffering off (only allowed in binary mode), 1 to select
line buffering (only usable in text mode), and an integer > 1 to indicate
the size of a fixed-size chunk buffer. When no buffering argument is
given, the default buffering policy works as follows:
* Binary files are buffered in fixed-size chunks; the size of the buffer
is chosen using a heuristic trying to determine the underlying device's
"block size" and falling back on `io.DEFAULT_BUFFER_SIZE`.
On many systems, the buffer will typically be 4096 or 8192 bytes long.
* "Interactive" text files (files for which isatty() returns True)
use line buffering. Other text files use the policy described above
for binary files.
encoding is the name of the encoding used to decode or encode the
file. This should only be used in text mode. The default encoding is
platform dependent, but any encoding supported by Python can be
passed. See the codecs module for the list of supported encodings.
errors is an optional string that specifies how encoding errors are to
be handled---this argument should not be used in binary mode. Pass
'strict' to raise a ValueError exception if there is an encoding error
(the default of None has the same effect), or pass 'ignore' to ignore
errors. (Note that ignoring encoding errors can lead to data loss.)
See the documentation for codecs.register or run 'help(codecs.Codec)'
for a list of the permitted encoding error strings.
newline controls how universal newlines works (it only applies to text
mode). 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 '' or '\n', no translation takes place. If newline is any
of the other legal values, any '\n' characters written are translated
to the given string.
If closefd is False, the underlying file descriptor will be kept open
when the file is closed. This does not work when a file name is given
and must be True in that case.
A custom opener can be used by passing a callable as *opener*. The
underlying file descriptor for the file object is then obtained by
calling *opener* with (*file*, *flags*). *opener* must return an open
file descriptor (passing os.open as *opener* results in functionality
similar to passing None).
open() returns a file object whose type depends on the mode, and
through which the standard file operations such as reading and writing
are performed. When open() is used to open a file in a text mode ('w',
'r', 'wt', 'rt', etc.), it returns a TextIOWrapper. When used to open
a file in a binary mode, the returned class varies: in read binary
mode, it returns a BufferedReader; in write binary and append binary
modes, it returns a BufferedWriter, and in read/write mode, it returns
a BufferedRandom.
It is also possible to use a string or bytearray as a file for both
reading and writing. For strings StringIO can be used like a file
opened in a text mode, and for bytes a BytesIO can be used like a file
opened in a binary mode.
io.open_code
Python Library Documentation: built-in function open_code in module _io
open_code(path)
Opens the provided file with the intent to import the contents.
This may perform extra validation beyond open(), but is otherwise interchangeable
with calling open(path, 'rb').
io.text_encoding
Python Library Documentation: built-in function text_encoding in module _io
text_encoding(encoding, stacklevel=2, /)
A helper function to choose the text encoding.
When encoding is not None, this function returns it.
Otherwise, this function returns the default text encoding
(i.e. "locale" or "utf-8" depends on UTF-8 mode).
This function emits an EncodingWarning if encoding is None and
sys.flags.warn_default_encoding is true.
This can be used in APIs with an encoding=None parameter.
However, please consider using encoding="utf-8" for new APIs.