doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
writelines(list) Writes the concatenated list of strings to the stream (possibly by reusing the write() method). The standard bytes-to-bytes codecs do not support this method.
python.library.codecs#codecs.StreamWriter.writelines
codecs.strict_errors(exception) Implements the 'strict' error handling: each encoding or decoding error raises a UnicodeError.
python.library.codecs#codecs.strict_errors
codecs.xmlcharrefreplace_errors(exception) Implements the 'xmlcharrefreplace' error handling (for encoding with text encodings only): the unencodable character is replaced by an appropriate XML character reference.
python.library.codecs#codecs.xmlcharrefreplace_errors
codeop — Compile Python code Source code: Lib/codeop.py The codeop module provides utilities upon which the Python read-eval-print loop can be emulated, as is done in the code module. As a result, you probably don’t want to use the module directly; if you want to include such a loop in your program you probably want to...
python.library.codeop
class codeop.CommandCompiler Instances of this class have __call__() methods identical in signature to compile_command(); the difference is that if the instance compiles program text containing a __future__ statement, the instance ‘remembers’ and compiles all subsequent program texts with the statement in force.
python.library.codeop#codeop.CommandCompiler
class codeop.Compile Instances of this class have __call__() methods identical in signature to the built-in function compile(), but with the difference that if the instance compiles program text containing a __future__ statement, the instance ‘remembers’ and compiles all subsequent program texts with the statement in...
python.library.codeop#codeop.Compile
codeop.compile_command(source, filename="<input>", symbol="single") Tries to compile source, which should be a string of Python code and return a code object if source is valid Python code. In that case, the filename attribute of the code object will be filename, which defaults to '<input>'. Returns None if source is...
python.library.codeop#codeop.compile_command
collections — Container datatypes Source code: Lib/collections/__init__.py This module implements specialized container datatypes providing alternatives to Python’s general purpose built-in containers, dict, list, set, and tuple. namedtuple() factory function for creating tuple subclasses with named fields deque li...
python.library.collections
collections.abc — Abstract Base Classes for Containers New in version 3.3: Formerly, this module was part of the collections module. Source code: Lib/_collections_abc.py This module provides abstract base classes that can be used to test whether a class provides a particular interface; for example, whether it is hash...
python.library.collections.abc
class collections.abc.AsyncGenerator ABC for asynchronous generator classes that implement the protocol defined in PEP 525 and PEP 492. New in version 3.6.
python.library.collections.abc#collections.abc.AsyncGenerator
class collections.abc.AsyncIterable ABC for classes that provide __aiter__ method. See also the definition of asynchronous iterable. New in version 3.5.
python.library.collections.abc#collections.abc.AsyncIterable
class collections.abc.AsyncIterator ABC for classes that provide __aiter__ and __anext__ methods. See also the definition of asynchronous iterator. New in version 3.5.
python.library.collections.abc#collections.abc.AsyncIterator
class collections.abc.Awaitable ABC for awaitable objects, which can be used in await expressions. Custom implementations must provide the __await__() method. Coroutine objects and instances of the Coroutine ABC are all instances of this ABC. Note In CPython, generator-based coroutines (generators decorated with typ...
python.library.collections.abc#collections.abc.Awaitable
class collections.abc.Sequence class collections.abc.MutableSequence class collections.abc.ByteString ABCs for read-only and mutable sequences. Implementation note: Some of the mixin methods, such as __iter__(), __reversed__() and index(), make repeated calls to the underlying __getitem__() method. Consequently, ...
python.library.collections.abc#collections.abc.ByteString
class collections.abc.Callable ABC for classes that provide the __call__() method.
python.library.collections.abc#collections.abc.Callable
class collections.abc.Collection ABC for sized iterable container classes. New in version 3.6.
python.library.collections.abc#collections.abc.Collection
class collections.abc.Container ABC for classes that provide the __contains__() method.
python.library.collections.abc#collections.abc.Container
class collections.abc.Coroutine ABC for coroutine compatible classes. These implement the following methods, defined in Coroutine Objects: send(), throw(), and close(). Custom implementations must also implement __await__(). All Coroutine instances are also instances of Awaitable. See also the definition of coroutine...
python.library.collections.abc#collections.abc.Coroutine
class collections.abc.Generator ABC for generator classes that implement the protocol defined in PEP 342 that extends iterators with the send(), throw() and close() methods. See also the definition of generator. New in version 3.5.
python.library.collections.abc#collections.abc.Generator
class collections.abc.Hashable ABC for classes that provide the __hash__() method.
python.library.collections.abc#collections.abc.Hashable
class collections.abc.MappingView class collections.abc.ItemsView class collections.abc.KeysView class collections.abc.ValuesView ABCs for mapping, items, keys, and values views.
python.library.collections.abc#collections.abc.ItemsView
class collections.abc.Iterable ABC for classes that provide the __iter__() method. Checking isinstance(obj, Iterable) detects classes that are registered as Iterable or that have an __iter__() method, but it does not detect classes that iterate with the __getitem__() method. The only reliable way to determine whether...
python.library.collections.abc#collections.abc.Iterable
class collections.abc.Iterator ABC for classes that provide the __iter__() and __next__() methods. See also the definition of iterator.
python.library.collections.abc#collections.abc.Iterator
class collections.abc.MappingView class collections.abc.ItemsView class collections.abc.KeysView class collections.abc.ValuesView ABCs for mapping, items, keys, and values views.
python.library.collections.abc#collections.abc.KeysView
class collections.abc.Mapping class collections.abc.MutableMapping ABCs for read-only and mutable mappings.
python.library.collections.abc#collections.abc.Mapping
class collections.abc.MappingView class collections.abc.ItemsView class collections.abc.KeysView class collections.abc.ValuesView ABCs for mapping, items, keys, and values views.
python.library.collections.abc#collections.abc.MappingView
class collections.abc.Mapping class collections.abc.MutableMapping ABCs for read-only and mutable mappings.
python.library.collections.abc#collections.abc.MutableMapping
class collections.abc.Sequence class collections.abc.MutableSequence class collections.abc.ByteString ABCs for read-only and mutable sequences. Implementation note: Some of the mixin methods, such as __iter__(), __reversed__() and index(), make repeated calls to the underlying __getitem__() method. Consequently, ...
python.library.collections.abc#collections.abc.MutableSequence
class collections.abc.Set class collections.abc.MutableSet ABCs for read-only and mutable sets.
python.library.collections.abc#collections.abc.MutableSet
class collections.abc.Reversible ABC for iterable classes that also provide the __reversed__() method. New in version 3.6.
python.library.collections.abc#collections.abc.Reversible
class collections.abc.Sequence class collections.abc.MutableSequence class collections.abc.ByteString ABCs for read-only and mutable sequences. Implementation note: Some of the mixin methods, such as __iter__(), __reversed__() and index(), make repeated calls to the underlying __getitem__() method. Consequently, ...
python.library.collections.abc#collections.abc.Sequence
class collections.abc.Set class collections.abc.MutableSet ABCs for read-only and mutable sets.
python.library.collections.abc#collections.abc.Set
class collections.abc.Sized ABC for classes that provide the __len__() method.
python.library.collections.abc#collections.abc.Sized
class collections.abc.MappingView class collections.abc.ItemsView class collections.abc.KeysView class collections.abc.ValuesView ABCs for mapping, items, keys, and values views.
python.library.collections.abc#collections.abc.ValuesView
class collections.ChainMap(*maps) A ChainMap groups multiple dicts or other mappings together to create a single, updateable view. If no maps are specified, a single empty dictionary is provided so that a new chain always has at least one mapping. The underlying mappings are stored in a list. That list is public and ...
python.library.collections#collections.ChainMap
maps A user updateable list of mappings. The list is ordered from first-searched to last-searched. It is the only stored state and can be modified to change which mappings are searched. The list should always contain at least one mapping.
python.library.collections#collections.ChainMap.maps
new_child(m=None) Returns a new ChainMap containing a new map followed by all of the maps in the current instance. If m is specified, it becomes the new map at the front of the list of mappings; if not specified, an empty dict is used, so that a call to d.new_child() is equivalent to: ChainMap({}, *d.maps). This meth...
python.library.collections#collections.ChainMap.new_child
parents Property returning a new ChainMap containing all of the maps in the current instance except the first one. This is useful for skipping the first map in the search. Use cases are similar to those for the nonlocal keyword used in nested scopes. The use cases also parallel those for the built-in super() function...
python.library.collections#collections.ChainMap.parents
class collections.Counter([iterable-or-mapping]) A Counter is a dict subclass for counting hashable objects. It is a collection where elements are stored as dictionary keys and their counts are stored as dictionary values. Counts are allowed to be any integer value including zero or negative counts. The Counter class...
python.library.collections#collections.Counter
elements() Return an iterator over elements repeating each as many times as its count. Elements are returned in the order first encountered. If an element’s count is less than one, elements() will ignore it. >>> c = Counter(a=4, b=2, c=0, d=-2) >>> sorted(c.elements()) ['a', 'a', 'a', 'a', 'b', 'b']
python.library.collections#collections.Counter.elements
fromkeys(iterable) This class method is not implemented for Counter objects.
python.library.collections#collections.Counter.fromkeys
most_common([n]) Return a list of the n most common elements and their counts from the most common to the least. If n is omitted or None, most_common() returns all elements in the counter. Elements with equal counts are ordered in the order first encountered: >>> Counter('abracadabra').most_common(3) [('a', 5), ('b',...
python.library.collections#collections.Counter.most_common
subtract([iterable-or-mapping]) Elements are subtracted from an iterable or from another mapping (or counter). Like dict.update() but subtracts counts instead of replacing them. Both inputs and outputs may be zero or negative. >>> c = Counter(a=4, b=2, c=0, d=-2) >>> d = Counter(a=1, b=2, c=3, d=4) >>> c.subtract(d) ...
python.library.collections#collections.Counter.subtract
update([iterable-or-mapping]) Elements are counted from an iterable or added-in from another mapping (or counter). Like dict.update() but adds counts instead of replacing them. Also, the iterable is expected to be a sequence of elements, not a sequence of (key, value) pairs.
python.library.collections#collections.Counter.update
class collections.defaultdict([default_factory[, ...]]) Returns a new dictionary-like object. defaultdict is a subclass of the built-in dict class. It overrides one method and adds one writable instance variable. The remaining functionality is the same as for the dict class and is not documented here. The first argum...
python.library.collections#collections.defaultdict
default_factory This attribute is used by the __missing__() method; it is initialized from the first argument to the constructor, if present, or to None, if absent.
python.library.collections#collections.defaultdict.default_factory
__missing__(key) If the default_factory attribute is None, this raises a KeyError exception with the key as argument. If default_factory is not None, it is called without arguments to provide a default value for the given key, this value is inserted in the dictionary for the key, and returned. If calling default_fact...
python.library.collections#collections.defaultdict.__missing__
class collections.deque([iterable[, maxlen]]) Returns a new deque object initialized left-to-right (using append()) with data from iterable. If iterable is not specified, the new deque is empty. Deques are a generalization of stacks and queues (the name is pronounced “deck” and is short for “double-ended queue”). Deq...
python.library.collections#collections.deque
append(x) Add x to the right side of the deque.
python.library.collections#collections.deque.append
appendleft(x) Add x to the left side of the deque.
python.library.collections#collections.deque.appendleft
clear() Remove all elements from the deque leaving it with length 0.
python.library.collections#collections.deque.clear
copy() Create a shallow copy of the deque. New in version 3.5.
python.library.collections#collections.deque.copy
count(x) Count the number of deque elements equal to x. New in version 3.2.
python.library.collections#collections.deque.count
extend(iterable) Extend the right side of the deque by appending elements from the iterable argument.
python.library.collections#collections.deque.extend
extendleft(iterable) Extend the left side of the deque by appending elements from iterable. Note, the series of left appends results in reversing the order of elements in the iterable argument.
python.library.collections#collections.deque.extendleft
index(x[, start[, stop]]) Return the position of x in the deque (at or after index start and before index stop). Returns the first match or raises ValueError if not found. New in version 3.5.
python.library.collections#collections.deque.index
insert(i, x) Insert x into the deque at position i. If the insertion would cause a bounded deque to grow beyond maxlen, an IndexError is raised. New in version 3.5.
python.library.collections#collections.deque.insert
maxlen Maximum size of a deque or None if unbounded. New in version 3.1.
python.library.collections#collections.deque.maxlen
pop() Remove and return an element from the right side of the deque. If no elements are present, raises an IndexError.
python.library.collections#collections.deque.pop
popleft() Remove and return an element from the left side of the deque. If no elements are present, raises an IndexError.
python.library.collections#collections.deque.popleft
remove(value) Remove the first occurrence of value. If not found, raises a ValueError.
python.library.collections#collections.deque.remove
reverse() Reverse the elements of the deque in-place and then return None. New in version 3.2.
python.library.collections#collections.deque.reverse
rotate(n=1) Rotate the deque n steps to the right. If n is negative, rotate to the left. When the deque is not empty, rotating one step to the right is equivalent to d.appendleft(d.pop()), and rotating one step to the left is equivalent to d.append(d.popleft()).
python.library.collections#collections.deque.rotate
collections.namedtuple(typename, field_names, *, rename=False, defaults=None, module=None) Returns a new tuple subclass named typename. The new subclass is used to create tuple-like objects that have fields accessible by attribute lookup as well as being indexable and iterable. Instances of the subclass also have a h...
python.library.collections#collections.namedtuple
class collections.OrderedDict([items]) Return an instance of a dict subclass that has methods specialized for rearranging dictionary order. New in version 3.1. popitem(last=True) The popitem() method for ordered dictionaries returns and removes a (key, value) pair. The pairs are returned in LIFO order if last i...
python.library.collections#collections.OrderedDict
move_to_end(key, last=True) Move an existing key to either end of an ordered dictionary. The item is moved to the right end if last is true (the default) or to the beginning if last is false. Raises KeyError if the key does not exist: >>> d = OrderedDict.fromkeys('abcde') >>> d.move_to_end('b') >>> ''.join(d.keys()) ...
python.library.collections#collections.OrderedDict.move_to_end
popitem(last=True) The popitem() method for ordered dictionaries returns and removes a (key, value) pair. The pairs are returned in LIFO order if last is true or FIFO order if false.
python.library.collections#collections.OrderedDict.popitem
somenamedtuple._asdict() Return a new dict which maps field names to their corresponding values: >>> p = Point(x=11, y=22) >>> p._asdict() {'x': 11, 'y': 22} Changed in version 3.1: Returns an OrderedDict instead of a regular dict. Changed in version 3.8: Returns a regular dict instead of an OrderedDict. As of Py...
python.library.collections#collections.somenamedtuple._asdict
somenamedtuple._fields Tuple of strings listing the field names. Useful for introspection and for creating new named tuple types from existing named tuples. >>> p._fields # view the field names ('x', 'y') >>> Color = namedtuple('Color', 'red green blue') >>> Pixel = namedtuple('Pixel', Point._fields + Col...
python.library.collections#collections.somenamedtuple._fields
somenamedtuple._field_defaults Dictionary mapping field names to default values. >>> Account = namedtuple('Account', ['type', 'balance'], defaults=[0]) >>> Account._field_defaults {'balance': 0} >>> Account('premium') Account(type='premium', balance=0)
python.library.collections#collections.somenamedtuple._field_defaults
classmethod somenamedtuple._make(iterable) Class method that makes a new instance from an existing sequence or iterable. >>> t = [11, 22] >>> Point._make(t) Point(x=11, y=22)
python.library.collections#collections.somenamedtuple._make
somenamedtuple._replace(**kwargs) Return a new instance of the named tuple replacing specified fields with new values: >>> p = Point(x=11, y=22) >>> p._replace(x=33) Point(x=33, y=22) >>> for partnum, record in inventory.items(): ... inventory[partnum] = record._replace(price=newprices[partnum], timestamp=time.n...
python.library.collections#collections.somenamedtuple._replace
class collections.UserDict([initialdata]) Class that simulates a dictionary. The instance’s contents are kept in a regular dictionary, which is accessible via the data attribute of UserDict instances. If initialdata is provided, data is initialized with its contents; note that a reference to initialdata will not be k...
python.library.collections#collections.UserDict
data A real dictionary used to store the contents of the UserDict class.
python.library.collections#collections.UserDict.data
class collections.UserList([list]) Class that simulates a list. The instance’s contents are kept in a regular list, which is accessible via the data attribute of UserList instances. The instance’s contents are initially set to a copy of list, defaulting to the empty list []. list can be any iterable, for example a re...
python.library.collections#collections.UserList
data A real list object used to store the contents of the UserList class.
python.library.collections#collections.UserList.data
class collections.UserString(seq) Class that simulates a string object. The instance’s content is kept in a regular string object, which is accessible via the data attribute of UserString instances. The instance’s contents are initially set to a copy of seq. The seq argument can be any object which can be converted i...
python.library.collections#collections.UserString
data A real str object used to store the contents of the UserString class.
python.library.collections#collections.UserString.data
colorsys — Conversions between color systems Source code: Lib/colorsys.py The colorsys module defines bidirectional conversions of color values between colors expressed in the RGB (Red Green Blue) color space used in computer monitors and three other coordinate systems: YIQ, HLS (Hue Lightness Saturation) and HSV (Hue ...
python.library.colorsys
colorsys.hls_to_rgb(h, l, s) Convert the color from HLS coordinates to RGB coordinates.
python.library.colorsys#colorsys.hls_to_rgb
colorsys.hsv_to_rgb(h, s, v) Convert the color from HSV coordinates to RGB coordinates.
python.library.colorsys#colorsys.hsv_to_rgb
colorsys.rgb_to_hls(r, g, b) Convert the color from RGB coordinates to HLS coordinates.
python.library.colorsys#colorsys.rgb_to_hls
colorsys.rgb_to_hsv(r, g, b) Convert the color from RGB coordinates to HSV coordinates.
python.library.colorsys#colorsys.rgb_to_hsv
colorsys.rgb_to_yiq(r, g, b) Convert the color from RGB coordinates to YIQ coordinates.
python.library.colorsys#colorsys.rgb_to_yiq
colorsys.yiq_to_rgb(y, i, q) Convert the color from YIQ coordinates to RGB coordinates.
python.library.colorsys#colorsys.yiq_to_rgb
compile(source, filename, mode, flags=0, dont_inherit=False, optimize=-1) Compile the source into a code or AST object. Code objects can be executed by exec() or eval(). source can either be a normal string, a byte string, or an AST object. Refer to the ast module documentation for information on how to work with AST...
python.library.functions#compile
compileall — Byte-compile Python libraries Source code: Lib/compileall.py This module provides some utility functions to support installing Python libraries. These functions compile Python source files in a directory tree. This module can be used to create the cached byte-code files at library installation time, which ...
python.library.compileall
compileall.compile_dir(dir, maxlevels=sys.getrecursionlimit(), ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1, workers=1, invalidation_mode=None, *, stripdir=None, prependdir=None, limit_sl_dest=None, hardlink_dupes=False) Recursively descend the directory tree named by dir, compiling all .py fil...
python.library.compileall#compileall.compile_dir
compileall.compile_file(fullname, ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1, invalidation_mode=None, *, stripdir=None, prependdir=None, limit_sl_dest=None, hardlink_dupes=False) Compile the file with path fullname. Return a true value if the file compiled successfully, and a false value othe...
python.library.compileall#compileall.compile_file
compileall.compile_path(skip_curdir=True, maxlevels=0, force=False, quiet=0, legacy=False, optimize=-1, invalidation_mode=None) Byte-compile all the .py files found along sys.path. Return a true value if all the files compiled successfully, and a false value otherwise. If skip_curdir is true (the default), the curren...
python.library.compileall#compileall.compile_path
class complex([real[, imag]]) Return a complex number with the value real + imag*1j or convert a string or number to a complex number. If the first parameter is a string, it will be interpreted as a complex number and the function must be called without a second parameter. The second parameter can never be a string. ...
python.library.functions#complex
concurrent.futures — Launching parallel tasks New in version 3.2. Source code: Lib/concurrent/futures/thread.py and Lib/concurrent/futures/process.py The concurrent.futures module provides a high-level interface for asynchronously executing callables. The asynchronous execution can be performed with threads, using Th...
python.library.concurrent.futures
concurrent.futures.as_completed(fs, timeout=None) Returns an iterator over the Future instances (possibly created by different Executor instances) given by fs that yields futures as they complete (finished or cancelled futures). Any futures given by fs that are duplicated will be returned once. Any futures that compl...
python.library.concurrent.futures#concurrent.futures.as_completed
exception concurrent.futures.BrokenExecutor Derived from RuntimeError, this exception class is raised when an executor is broken for some reason, and cannot be used to submit or execute new tasks. New in version 3.7.
python.library.concurrent.futures#concurrent.futures.BrokenExecutor
exception concurrent.futures.CancelledError Raised when a future is cancelled.
python.library.concurrent.futures#concurrent.futures.CancelledError
class concurrent.futures.Executor An abstract class that provides methods to execute calls asynchronously. It should not be used directly, but through its concrete subclasses. submit(fn, /, *args, **kwargs) Schedules the callable, fn, to be executed as fn(*args **kwargs) and returns a Future object representing t...
python.library.concurrent.futures#concurrent.futures.Executor
map(func, *iterables, timeout=None, chunksize=1) Similar to map(func, *iterables) except: the iterables are collected immediately rather than lazily; func is executed asynchronously and several calls to func may be made concurrently. The returned iterator raises a concurrent.futures.TimeoutError if __next__() is c...
python.library.concurrent.futures#concurrent.futures.Executor.map
shutdown(wait=True, *, cancel_futures=False) Signal the executor that it should free any resources that it is using when the currently pending futures are done executing. Calls to Executor.submit() and Executor.map() made after shutdown will raise RuntimeError. If wait is True then this method will not return until a...
python.library.concurrent.futures#concurrent.futures.Executor.shutdown
submit(fn, /, *args, **kwargs) Schedules the callable, fn, to be executed as fn(*args **kwargs) and returns a Future object representing the execution of the callable. with ThreadPoolExecutor(max_workers=1) as executor: future = executor.submit(pow, 323, 1235) print(future.result())
python.library.concurrent.futures#concurrent.futures.Executor.submit
class concurrent.futures.Future Encapsulates the asynchronous execution of a callable. Future instances are created by Executor.submit() and should not be created directly except for testing. cancel() Attempt to cancel the call. If the call is currently being executed or finished running and cannot be cancelled t...
python.library.concurrent.futures#concurrent.futures.Future