doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
inspect.trace(context=1) Return a list of frame records for the stack between the current frame and the frame in which an exception currently being handled was raised in. The first entry in the list represents the caller; the last entry represents where the exception was raised. Changed in version 3.5: A list of nam...
python.library.inspect#inspect.trace
inspect.unwrap(func, *, stop=None) Get the object wrapped by func. It follows the chain of __wrapped__ attributes returning the last object in the chain. stop is an optional callback accepting an object in the wrapper chain as its sole argument that allows the unwrapping to be terminated early if the callback returns...
python.library.inspect#inspect.unwrap
instance.__class__ The class to which a class instance belongs.
python.library.stdtypes#instance.__class__
class int([x]) class int(x, base=10) Return an integer object constructed from a number or string x, or return 0 if no arguments are given. If x defines __int__(), int(x) returns x.__int__(). If x defines __index__(), it returns x.__index__(). If x defines __trunc__(), it returns x.__trunc__(). For floating point n...
python.library.functions#int
int.as_integer_ratio() Return a pair of integers whose ratio is exactly equal to the original integer and with a positive denominator. The integer ratio of integers (whole numbers) is always the integer as the numerator and 1 as the denominator. New in version 3.8.
python.library.stdtypes#int.as_integer_ratio
int.bit_length() Return the number of bits necessary to represent an integer in binary, excluding the sign and leading zeros: >>> n = -37 >>> bin(n) '-0b100101' >>> n.bit_length() 6 More precisely, if x is nonzero, then x.bit_length() is the unique positive integer k such that 2**(k-1) <= abs(x) < 2**k. Equivalently...
python.library.stdtypes#int.bit_length
classmethod int.from_bytes(bytes, byteorder, *, signed=False) Return the integer represented by the given array of bytes. >>> int.from_bytes(b'\x00\x10', byteorder='big') 16 >>> int.from_bytes(b'\x00\x10', byteorder='little') 4096 >>> int.from_bytes(b'\xfc\x00', byteorder='big', signed=True) -1024 >>> int.from_bytes(...
python.library.stdtypes#int.from_bytes
int.to_bytes(length, byteorder, *, signed=False) Return an array of bytes representing an integer. >>> (1024).to_bytes(2, byteorder='big') b'\x04\x00' >>> (1024).to_bytes(10, byteorder='big') b'\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00' >>> (-1024).to_bytes(10, byteorder='big', signed=True) b'\xff\xff\xff\xff\xff\xff\...
python.library.stdtypes#int.to_bytes
exception InterruptedError Raised when a system call is interrupted by an incoming signal. Corresponds to errno EINTR. Changed in version 3.5: Python now retries system calls when a syscall is interrupted by a signal, except if the signal handler raises an exception (see PEP 475 for the rationale), instead of raisin...
python.library.exceptions#InterruptedError
io — Core tools for working with streams Source code: Lib/io.py Overview The io module provides Python’s main facilities for dealing with various types of I/O. There are three main types of I/O: text I/O, binary I/O and raw I/O. These are generic categories, and various backing stores can be used for each of them. A co...
python.library.io
exception io.BlockingIOError This is a compatibility alias for the builtin BlockingIOError exception.
python.library.io#io.BlockingIOError
class io.BufferedIOBase Base class for binary streams that support some kind of buffering. It inherits IOBase. There is no public constructor. The main difference with RawIOBase is that methods read(), readinto() and write() will try (respectively) to read as much input as requested or to consume all given output, at...
python.library.io#io.BufferedIOBase
detach() Separate the underlying raw stream from the buffer and return it. After the raw stream has been detached, the buffer is in an unusable state. Some buffers, like BytesIO, do not have the concept of a single raw stream to return from this method. They raise UnsupportedOperation. New in version 3.1.
python.library.io#io.BufferedIOBase.detach
raw The underlying raw stream (a RawIOBase instance) that BufferedIOBase deals with. This is not part of the BufferedIOBase API and may not exist on some implementations.
python.library.io#io.BufferedIOBase.raw
read(size=-1) Read and return up to size bytes. If the argument is omitted, None, or negative, data is read and returned until EOF is reached. An empty bytes object is returned if the stream is already at EOF. If the argument is positive, and the underlying raw stream is not interactive, multiple raw reads may be iss...
python.library.io#io.BufferedIOBase.read
read1([size]) Read and return up to size bytes, with at most one call to the underlying raw stream’s read() (or readinto()) method. This can be useful if you are implementing your own buffering on top of a BufferedIOBase object. If size is -1 (the default), an arbitrary number of bytes are returned (more than zero un...
python.library.io#io.BufferedIOBase.read1
readinto(b) Read bytes into a pre-allocated, writable bytes-like object b and return the number of bytes read. For example, b might be a bytearray. Like read(), multiple reads may be issued to the underlying raw stream, unless the latter is interactive. A BlockingIOError is raised if the underlying raw stream is in n...
python.library.io#io.BufferedIOBase.readinto
readinto1(b) Read bytes into a pre-allocated, writable bytes-like object b, using at most one call to the underlying raw stream’s read() (or readinto()) method. Return the number of bytes read. A BlockingIOError is raised if the underlying raw stream is in non blocking-mode, and has no data available at the moment. ...
python.library.io#io.BufferedIOBase.readinto1
write(b) Write the given bytes-like object, b, and return the number of bytes written (always equal to the length of b in bytes, since if the write fails an OSError will be raised). Depending on the actual implementation, these bytes may be readily written to the underlying stream, or held in a buffer for performance...
python.library.io#io.BufferedIOBase.write
class io.BufferedRandom(raw, buffer_size=DEFAULT_BUFFER_SIZE) A buffered binary stream providing higher-level access to a seekable RawIOBase raw binary stream. It inherits BufferedReader and BufferedWriter. The constructor creates a reader and writer for a seekable raw stream, given in the first argument. If the buff...
python.library.io#io.BufferedRandom
class io.BufferedReader(raw, buffer_size=DEFAULT_BUFFER_SIZE) A buffered binary stream providing higher-level access to a readable, non seekable RawIOBase raw binary stream. It inherits BufferedIOBase. When reading data from this object, a larger amount of data may be requested from the underlying raw stream, and kep...
python.library.io#io.BufferedReader
peek([size]) Return bytes from the stream without advancing the position. At most one single read on the raw stream is done to satisfy the call. The number of bytes returned may be less or more than requested.
python.library.io#io.BufferedReader.peek
read([size]) Read and return size bytes, or if size is not given or negative, until EOF or if the read call would block in non-blocking mode.
python.library.io#io.BufferedReader.read
read1([size]) Read and return up to size bytes with only one call on the raw stream. If at least one byte is buffered, only buffered bytes are returned. Otherwise, one raw stream read call is made. Changed in version 3.7: The size argument is now optional.
python.library.io#io.BufferedReader.read1
class io.BufferedRWPair(reader, writer, buffer_size=DEFAULT_BUFFER_SIZE) A buffered binary stream providing higher-level access to two non seekable RawIOBase raw binary streams—one readable, the other writeable. It inherits BufferedIOBase. reader and writer are RawIOBase objects that are readable and writeable respec...
python.library.io#io.BufferedRWPair
class io.BufferedWriter(raw, buffer_size=DEFAULT_BUFFER_SIZE) A buffered binary stream providing higher-level access to a writeable, non seekable RawIOBase raw binary stream. It inherits BufferedIOBase. When writing to this object, data is normally placed into an internal buffer. The buffer will be written out to the...
python.library.io#io.BufferedWriter
flush() Force bytes held in the buffer into the raw stream. A BlockingIOError should be raised if the raw stream blocks.
python.library.io#io.BufferedWriter.flush
write(b) Write the bytes-like object, b, and return the number of bytes written. When in non-blocking mode, a BlockingIOError is raised if the buffer needs to be written out but the raw stream blocks.
python.library.io#io.BufferedWriter.write
class io.BytesIO([initial_bytes]) A binary stream using an in-memory bytes buffer. It inherits BufferedIOBase. The buffer is discarded when the close() method is called. The optional argument initial_bytes is a bytes-like object that contains initial data. BytesIO provides or overrides these methods in addition to th...
python.library.io#io.BytesIO
getbuffer() Return a readable and writable view over the contents of the buffer without copying them. Also, mutating the view will transparently update the contents of the buffer: >>> b = io.BytesIO(b"abcdef") >>> view = b.getbuffer() >>> view[2:4] = b"56" >>> b.getvalue() b'ab56ef' Note As long as the view exists,...
python.library.io#io.BytesIO.getbuffer
getvalue() Return bytes containing the entire contents of the buffer.
python.library.io#io.BytesIO.getvalue
read1([size]) In BytesIO, this is the same as read(). Changed in version 3.7: The size argument is now optional.
python.library.io#io.BytesIO.read1
readinto1(b) In BytesIO, this is the same as readinto(). New in version 3.5.
python.library.io#io.BytesIO.readinto1
io.DEFAULT_BUFFER_SIZE An int containing the default buffer size used by the module’s buffered I/O classes. open() uses the file’s blksize (as obtained by os.stat()) if possible.
python.library.io#io.DEFAULT_BUFFER_SIZE
class io.FileIO(name, mode='r', closefd=True, opener=None) A raw binary stream representing an OS-level file containing bytes data. It inherits RawIOBase. The name can be one of two things: a character string or bytes object representing the path to the file which will be opened. In this case closefd must be True (t...
python.library.io#io.FileIO
mode The mode as given in the constructor.
python.library.io#io.FileIO.mode
name The file name. This is the file descriptor of the file when no name is given in the constructor.
python.library.io#io.FileIO.name
class io.IncrementalNewlineDecoder A helper codec that decodes newlines for universal newlines mode. It inherits codecs.IncrementalDecoder.
python.library.io#io.IncrementalNewlineDecoder
class io.IOBase The abstract base class for all I/O classes, acting on streams of bytes. There is no public constructor. This class provides empty abstract implementations for many methods that derived classes can override selectively; the default implementations represent a file that cannot be read, written or seeke...
python.library.io#io.IOBase
close() Flush and close this stream. This method has no effect if the file is already closed. Once the file is closed, any operation on the file (e.g. reading or writing) will raise a ValueError. As a convenience, it is allowed to call this method more than once; only the first call, however, will have an effect.
python.library.io#io.IOBase.close
closed True if the stream is closed.
python.library.io#io.IOBase.closed
fileno() Return the underlying file descriptor (an integer) of the stream if it exists. An OSError is raised if the IO object does not use a file descriptor.
python.library.io#io.IOBase.fileno
flush() Flush the write buffers of the stream if applicable. This does nothing for read-only and non-blocking streams.
python.library.io#io.IOBase.flush
isatty() Return True if the stream is interactive (i.e., connected to a terminal/tty device).
python.library.io#io.IOBase.isatty
readable() Return True if the stream can be read from. If False, read() will raise OSError.
python.library.io#io.IOBase.readable
readline(size=-1) Read and return one 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 newline argument to open() can be used to select the line terminator(s) recognized.
python.library.io#io.IOBase.readline
readlines(hint=-1) Read and 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. Note that it’s already possible to iterate on file objects using for line in file: ... wit...
python.library.io#io.IOBase.readlines
seek(offset, whence=SEEK_SET) Change the stream position to the given byte offset. offset is interpreted relative to the position indicated by whence. The default value for whence is SEEK_SET. Values for whence are: SEEK_SET or 0 – start of the stream (the default); offset should be zero or positive SEEK_CUR or 1 ...
python.library.io#io.IOBase.seek
seekable() Return True if the stream supports random access. If False, seek(), tell() and truncate() will raise OSError.
python.library.io#io.IOBase.seekable
tell() Return the current stream position.
python.library.io#io.IOBase.tell
truncate(size=None) Resize the stream to the given size in bytes (or the current position if size is not specified). The current stream position isn’t changed. This resizing can extend or reduce the current file size. In case of extension, the contents of the new file area depend on the platform (on most systems, add...
python.library.io#io.IOBase.truncate
writable() Return True if the stream supports writing. If False, write() and truncate() will raise OSError.
python.library.io#io.IOBase.writable
writelines(lines) Write a list of lines to the stream. Line separators are not added, so it is usual for each of the lines provided to have a line separator at the end.
python.library.io#io.IOBase.writelines
__del__() Prepare for object destruction. IOBase provides a default implementation of this method that calls the instance’s close() method.
python.library.io#io.IOBase.__del__
io.open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) This is an alias for the builtin open() function. This function raises an auditing event open with arguments path, mode and flags. The mode and flags arguments may have been modified or inferred from the origina...
python.library.io#io.open
io.open_code(path) Opens the provided file with mode 'rb'. This function should be used when the intent is to treat the contents as executable code. path should be a str and an absolute path. The behavior of this function may be overridden by an earlier call to the PyFile_SetOpenCodeHook(). However, assuming that pat...
python.library.io#io.open_code
class io.RawIOBase Base class for raw binary streams. It inherits IOBase. There is no public constructor. Raw binary streams typically provide low-level access to an underlying OS device or API, and do not try to encapsulate it in high-level primitives (this functionality is done at a higher-level in buffered binary ...
python.library.io#io.RawIOBase
read(size=-1) Read up to size bytes from the object and return them. As a convenience, if size is unspecified or -1, all bytes until EOF are returned. Otherwise, only one system call is ever made. Fewer than size bytes may be returned if the operating system call returns fewer than size bytes. If 0 bytes are returned...
python.library.io#io.RawIOBase.read
readall() Read and return all the bytes from the stream until EOF, using multiple calls to the stream if necessary.
python.library.io#io.RawIOBase.readall
readinto(b) Read bytes into a pre-allocated, writable bytes-like object b, and return the number of bytes read. For example, b might be a bytearray. If the object is in non-blocking mode and no bytes are available, None is returned.
python.library.io#io.RawIOBase.readinto
write(b) Write the given bytes-like object, b, to the underlying raw stream, and return the number of bytes written. This can be less than the length of b in bytes, depending on specifics of the underlying raw stream, and especially if it is in non-blocking mode. None is returned if the raw stream is set not to block...
python.library.io#io.RawIOBase.write
class io.StringIO(initial_value='', newline='\n') A text stream using an in-memory text buffer. It inherits TextIOBase. The text buffer is discarded when the close() method is called. The initial value of the buffer can be set by providing initial_value. If newline translation is enabled, newlines will be encoded as ...
python.library.io#io.StringIO
getvalue() Return a str containing the entire contents of the buffer. Newlines are decoded as if by read(), although the stream position is not changed.
python.library.io#io.StringIO.getvalue
class io.TextIOBase Base class for text streams. This class provides a character and line based interface to stream I/O. It inherits IOBase. There is no public constructor. TextIOBase provides or overrides these data attributes and methods in addition to those from IOBase: encoding The name of the encoding used t...
python.library.io#io.TextIOBase
buffer The underlying binary buffer (a BufferedIOBase instance) that TextIOBase deals with. This is not part of the TextIOBase API and may not exist in some implementations.
python.library.io#io.TextIOBase.buffer
detach() Separate the underlying binary buffer from the TextIOBase and return it. After the underlying buffer has been detached, the TextIOBase is in an unusable state. Some TextIOBase implementations, like StringIO, may not have the concept of an underlying buffer and calling this method will raise UnsupportedOperat...
python.library.io#io.TextIOBase.detach
encoding The name of the encoding used to decode the stream’s bytes into strings, and to encode strings into bytes.
python.library.io#io.TextIOBase.encoding
errors The error setting of the decoder or encoder.
python.library.io#io.TextIOBase.errors
newlines A string, a tuple of strings, or None, indicating the newlines translated so far. Depending on the implementation and the initial constructor flags, this may not be available.
python.library.io#io.TextIOBase.newlines
read(size=-1) Read and return at most size characters from the stream as a single str. If size is negative or None, reads until EOF.
python.library.io#io.TextIOBase.read
readline(size=-1) Read until newline or EOF and return a single str. If the stream is already at EOF, an empty string is returned. If size is specified, at most size characters will be read.
python.library.io#io.TextIOBase.readline
seek(offset, whence=SEEK_SET) Change the stream position to the given offset. Behaviour depends on the whence parameter. The default value for whence is SEEK_SET. SEEK_SET or 0: seek from the start of the stream (the default); offset must either be a number returned by TextIOBase.tell(), or zero. Any other offset v...
python.library.io#io.TextIOBase.seek
tell() Return the current stream position as an opaque number. The number does not usually represent a number of bytes in the underlying binary storage.
python.library.io#io.TextIOBase.tell
write(s) Write the string s to the stream and return the number of characters written.
python.library.io#io.TextIOBase.write
class io.TextIOWrapper(buffer, encoding=None, errors=None, newline=None, line_buffering=False, write_through=False) A buffered text stream providing higher-level access to a BufferedIOBase buffered binary stream. It inherits TextIOBase. encoding gives the name of the encoding that the stream will be decoded or encode...
python.library.io#io.TextIOWrapper
line_buffering Whether line buffering is enabled.
python.library.io#io.TextIOWrapper.line_buffering
reconfigure(*[, encoding][, errors][, newline][, line_buffering][, write_through]) Reconfigure this text stream using new settings for encoding, errors, newline, line_buffering and write_through. Parameters not specified keep current settings, except errors='strict' is used when encoding is specified but errors is no...
python.library.io#io.TextIOWrapper.reconfigure
write_through Whether writes are passed immediately to the underlying binary buffer. New in version 3.7.
python.library.io#io.TextIOWrapper.write_through
exception io.UnsupportedOperation An exception inheriting OSError and ValueError that is raised when an unsupported operation is called on a stream.
python.library.io#io.UnsupportedOperation
exception IOError
python.library.exceptions#IOError
ipaddress — IPv4/IPv6 manipulation library Source code: Lib/ipaddress.py ipaddress provides the capabilities to create, manipulate and operate on IPv4 and IPv6 addresses and networks. The functions and classes in this module make it straightforward to handle various tasks related to IP addresses, including checking whe...
python.library.ipaddress
exception ipaddress.AddressValueError(ValueError) Any value error related to the address.
python.library.ipaddress#ipaddress.AddressValueError
ipaddress.collapse_addresses(addresses) Return an iterator of the collapsed IPv4Network or IPv6Network objects. addresses is an iterator of IPv4Network or IPv6Network objects. A TypeError is raised if addresses contains mixed version objects. >>> [ipaddr for ipaddr in ... ipaddress.collapse_addresses([ipaddress.IPv4N...
python.library.ipaddress#ipaddress.collapse_addresses
ipaddress.get_mixed_type_key(obj) Return a key suitable for sorting between networks and addresses. Address and Network objects are not sortable by default; they’re fundamentally different, so the expression: IPv4Address('192.0.2.0') <= IPv4Network('192.0.2.0/24') doesn’t make sense. There are some times however, wh...
python.library.ipaddress#ipaddress.get_mixed_type_key
class ipaddress.IPv4Address(address) Construct an IPv4 address. An AddressValueError is raised if address is not a valid IPv4 address. The following constitutes a valid IPv4 address: A string in decimal-dot notation, consisting of four decimal integers in the inclusive range 0–255, separated by dots (e.g. 192.168.0....
python.library.ipaddress#ipaddress.IPv4Address
compressed
python.library.ipaddress#ipaddress.IPv4Address.compressed
exploded The string representation in dotted decimal notation. Leading zeroes are never included in the representation. As IPv4 does not define a shorthand notation for addresses with octets set to zero, these two attributes are always the same as str(addr) for IPv4 addresses. Exposing these attributes makes it easie...
python.library.ipaddress#ipaddress.IPv4Address.exploded
is_global True if the address is allocated for public networks. See iana-ipv4-special-registry (for IPv4) or iana-ipv6-special-registry (for IPv6). New in version 3.4.
python.library.ipaddress#ipaddress.IPv4Address.is_global
is_link_local True if the address is reserved for link-local usage. See RFC 3927.
python.library.ipaddress#ipaddress.IPv4Address.is_link_local
is_loopback True if this is a loopback address. See RFC 3330 (for IPv4) or RFC 2373 (for IPv6).
python.library.ipaddress#ipaddress.IPv4Address.is_loopback
is_multicast True if the address is reserved for multicast use. See RFC 3171 (for IPv4) or RFC 2373 (for IPv6).
python.library.ipaddress#ipaddress.IPv4Address.is_multicast
is_private True if the address is allocated for private networks. See iana-ipv4-special-registry (for IPv4) or iana-ipv6-special-registry (for IPv6).
python.library.ipaddress#ipaddress.IPv4Address.is_private
is_reserved True if the address is otherwise IETF reserved.
python.library.ipaddress#ipaddress.IPv4Address.is_reserved
is_unspecified True if the address is unspecified. See RFC 5735 (for IPv4) or RFC 2373 (for IPv6).
python.library.ipaddress#ipaddress.IPv4Address.is_unspecified
max_prefixlen The total number of bits in the address representation for this version: 32 for IPv4, 128 for IPv6. The prefix defines the number of leading bits in an address that are compared to determine whether or not an address is part of a network.
python.library.ipaddress#ipaddress.IPv4Address.max_prefixlen
packed The binary representation of this address - a bytes object of the appropriate length (most significant octet first). This is 4 bytes for IPv4 and 16 bytes for IPv6.
python.library.ipaddress#ipaddress.IPv4Address.packed
reverse_pointer The name of the reverse DNS PTR record for the IP address, e.g.: >>> ipaddress.ip_address("127.0.0.1").reverse_pointer '1.0.0.127.in-addr.arpa' >>> ipaddress.ip_address("2001:db8::1").reverse_pointer '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa' This is the name that coul...
python.library.ipaddress#ipaddress.IPv4Address.reverse_pointer
version The appropriate version number: 4 for IPv4, 6 for IPv6.
python.library.ipaddress#ipaddress.IPv4Address.version
IPv4Address.__format__(fmt) Returns a string representation of the IP address, controlled by an explicit format string. fmt can be one of the following: 's', the default option, equivalent to str(), 'b' for a zero-padded binary string, 'X' or 'x' for an uppercase or lowercase hexadecimal representation, or 'n', which...
python.library.ipaddress#ipaddress.IPv4Address.__format__
class ipaddress.IPv4Interface(address) Construct an IPv4 interface. The meaning of address is as in the constructor of IPv4Network, except that arbitrary host addresses are always accepted. IPv4Interface is a subclass of IPv4Address, so it inherits all the attributes from that class. In addition, the following attrib...
python.library.ipaddress#ipaddress.IPv4Interface