doc_content stringlengths 1 386k | doc_id stringlengths 5 188 |
|---|---|
add_done_callback(fn)
Attaches the callable fn to the future. fn will be called, with the future as its only argument, when the future is cancelled or finishes running. Added callables are called in the order that they were added and are always called in a thread belonging to the process that added them. If the calla... | python.library.concurrent.futures#concurrent.futures.Future.add_done_callback |
cancel()
Attempt to cancel the call. If the call is currently being executed or finished running and cannot be cancelled then the method will return False, otherwise the call will be cancelled and the method will return True. | python.library.concurrent.futures#concurrent.futures.Future.cancel |
cancelled()
Return True if the call was successfully cancelled. | python.library.concurrent.futures#concurrent.futures.Future.cancelled |
done()
Return True if the call was successfully cancelled or finished running. | python.library.concurrent.futures#concurrent.futures.Future.done |
exception(timeout=None)
Return the exception raised by the call. If the call hasn’t yet completed then this method will wait up to timeout seconds. If the call hasn’t completed in timeout seconds, then a concurrent.futures.TimeoutError will be raised. timeout can be an int or float. If timeout is not specified or Non... | python.library.concurrent.futures#concurrent.futures.Future.exception |
result(timeout=None)
Return the value returned by the call. If the call hasn’t yet completed then this method will wait up to timeout seconds. If the call hasn’t completed in timeout seconds, then a concurrent.futures.TimeoutError will be raised. timeout can be an int or float. If timeout is not specified or None, th... | python.library.concurrent.futures#concurrent.futures.Future.result |
running()
Return True if the call is currently being executed and cannot be cancelled. | python.library.concurrent.futures#concurrent.futures.Future.running |
set_exception(exception)
Sets the result of the work associated with the Future to the Exception exception. This method should only be used by Executor implementations and unit tests. Changed in version 3.8: This method raises concurrent.futures.InvalidStateError if the Future is already done. | python.library.concurrent.futures#concurrent.futures.Future.set_exception |
set_result(result)
Sets the result of the work associated with the Future to result. This method should only be used by Executor implementations and unit tests. Changed in version 3.8: This method raises concurrent.futures.InvalidStateError if the Future is already done. | python.library.concurrent.futures#concurrent.futures.Future.set_result |
set_running_or_notify_cancel()
This method should only be called by Executor implementations before executing the work associated with the Future and by unit tests. If the method returns False then the Future was cancelled, i.e. Future.cancel() was called and returned True. Any threads waiting on the Future completin... | python.library.concurrent.futures#concurrent.futures.Future.set_running_or_notify_cancel |
exception concurrent.futures.InvalidStateError
Raised when an operation is performed on a future that is not allowed in the current state. New in version 3.8. | python.library.concurrent.futures#concurrent.futures.InvalidStateError |
exception concurrent.futures.process.BrokenProcessPool
Derived from BrokenExecutor (formerly RuntimeError), this exception class is raised when one of the workers of a ProcessPoolExecutor has terminated in a non-clean fashion (for example, if it was killed from the outside). New in version 3.3. | python.library.concurrent.futures#concurrent.futures.process.BrokenProcessPool |
class concurrent.futures.ProcessPoolExecutor(max_workers=None, mp_context=None, initializer=None, initargs=())
An Executor subclass that executes calls asynchronously using a pool of at most max_workers processes. If max_workers is None or not given, it will default to the number of processors on the machine. If max_... | python.library.concurrent.futures#concurrent.futures.ProcessPoolExecutor |
exception concurrent.futures.thread.BrokenThreadPool
Derived from BrokenExecutor, this exception class is raised when one of the workers of a ThreadPoolExecutor has failed initializing. New in version 3.7. | python.library.concurrent.futures#concurrent.futures.thread.BrokenThreadPool |
class concurrent.futures.ThreadPoolExecutor(max_workers=None, thread_name_prefix='', initializer=None, initargs=())
An Executor subclass that uses a pool of at most max_workers threads to execute calls asynchronously. initializer is an optional callable that is called at the start of each worker thread; initargs is a... | python.library.concurrent.futures#concurrent.futures.ThreadPoolExecutor |
exception concurrent.futures.TimeoutError
Raised when a future operation exceeds the given timeout. | python.library.concurrent.futures#concurrent.futures.TimeoutError |
concurrent.futures.wait(fs, timeout=None, return_when=ALL_COMPLETED)
Wait for the Future instances (possibly created by different Executor instances) given by fs to complete. Returns a named 2-tuple of sets. The first set, named done, contains the futures that completed (finished or cancelled futures) before the wait... | python.library.concurrent.futures#concurrent.futures.wait |
configparser — Configuration file parser Source code: Lib/configparser.py This module provides the ConfigParser class which implements a basic configuration language which provides a structure similar to what’s found in Microsoft Windows INI files. You can use this to write Python programs which can be customized by en... | python.library.configparser |
class configparser.BasicInterpolation
The default implementation used by ConfigParser. It enables values to contain format strings which refer to other values in the same section, or values in the special default section 1. Additional default values can be provided on initialization. For example: [Paths]
home_dir: /U... | python.library.configparser#configparser.BasicInterpolation |
class configparser.ConfigParser(defaults=None, dict_type=dict, allow_no_value=False, delimiters=('=', ':'), comment_prefixes=('#', ';'), inline_comment_prefixes=None, strict=True, empty_lines_in_values=True, default_section=configparser.DEFAULTSECT, interpolation=BasicInterpolation(), converters={})
The main configur... | python.library.configparser#configparser.ConfigParser |
add_section(section)
Add a section named section to the instance. If a section by the given name already exists, DuplicateSectionError is raised. If the default section name is passed, ValueError is raised. The name of the section must be a string; if not, TypeError is raised. Changed in version 3.2: Non-string sect... | python.library.configparser#configparser.ConfigParser.add_section |
ConfigParser.BOOLEAN_STATES
By default when using getboolean(), config parsers consider the following values True: '1', 'yes', 'true', 'on' and the following values False: '0', 'no', 'false', 'off'. You can override this by specifying a custom dictionary of strings and their Boolean outcomes. For example: >>> custom ... | python.library.configparser#configparser.ConfigParser.BOOLEAN_STATES |
defaults()
Return a dictionary containing the instance-wide defaults. | python.library.configparser#configparser.ConfigParser.defaults |
get(section, option, *, raw=False, vars=None[, fallback])
Get an option value for the named section. If vars is provided, it must be a dictionary. The option is looked up in vars (if provided), section, and in DEFAULTSECT in that order. If the key is not found and fallback is provided, it is used as a fallback value.... | python.library.configparser#configparser.ConfigParser.get |
getboolean(section, option, *, raw=False, vars=None[, fallback])
A convenience method which coerces the option in the specified section to a Boolean value. Note that the accepted values for the option are '1', 'yes', 'true', and 'on', which cause this method to return True, and '0', 'no', 'false', and 'off', which ca... | python.library.configparser#configparser.ConfigParser.getboolean |
getfloat(section, option, *, raw=False, vars=None[, fallback])
A convenience method which coerces the option in the specified section to a floating point number. See get() for explanation of raw, vars and fallback. | python.library.configparser#configparser.ConfigParser.getfloat |
getint(section, option, *, raw=False, vars=None[, fallback])
A convenience method which coerces the option in the specified section to an integer. See get() for explanation of raw, vars and fallback. | python.library.configparser#configparser.ConfigParser.getint |
has_option(section, option)
If the given section exists, and contains the given option, return True; otherwise return False. If the specified section is None or an empty string, DEFAULT is assumed. | python.library.configparser#configparser.ConfigParser.has_option |
has_section(section)
Indicates whether the named section is present in the configuration. The default section is not acknowledged. | python.library.configparser#configparser.ConfigParser.has_section |
items(raw=False, vars=None)
items(section, raw=False, vars=None)
When section is not given, return a list of section_name, section_proxy pairs, including DEFAULTSECT. Otherwise, return a list of name, value pairs for the options in the given section. Optional arguments have the same meaning as for the get() method.... | python.library.configparser#configparser.ConfigParser.items |
options(section)
Return a list of options available in the specified section. | python.library.configparser#configparser.ConfigParser.options |
optionxform(option)
Transforms the option name option as found in an input file or as passed in by client code to the form that should be used in the internal structures. The default implementation returns a lower-case version of option; subclasses may override this or client code can set an attribute of this name on... | python.library.configparser#configparser.ConfigParser.optionxform |
read(filenames, encoding=None)
Attempt to read and parse an iterable of filenames, returning a list of filenames which were successfully parsed. If filenames is a string, a bytes object or a path-like object, it is treated as a single filename. If a file named in filenames cannot be opened, that file will be ignored.... | python.library.configparser#configparser.ConfigParser.read |
readfp(fp, filename=None)
Deprecated since version 3.2: Use read_file() instead. Changed in version 3.2: readfp() now iterates on fp instead of calling fp.readline(). For existing code calling readfp() with arguments which don’t support iteration, the following generator may be used as a wrapper around the file-l... | python.library.configparser#configparser.ConfigParser.readfp |
read_dict(dictionary, source='<dict>')
Load configuration from any object that provides a dict-like items() method. Keys are section names, values are dictionaries with keys and values that should be present in the section. If the used dictionary type preserves order, sections and their keys will be added in order. V... | python.library.configparser#configparser.ConfigParser.read_dict |
read_file(f, source=None)
Read and parse configuration data from f which must be an iterable yielding Unicode strings (for example files opened in text mode). Optional argument source specifies the name of the file being read. If not given and f has a name attribute, that is used for source; the default is '<???>'. ... | python.library.configparser#configparser.ConfigParser.read_file |
read_string(string, source='<string>')
Parse configuration data from a string. Optional argument source specifies a context-specific name of the string passed. If not given, '<string>' is used. This should commonly be a filesystem path or a URL. New in version 3.2. | python.library.configparser#configparser.ConfigParser.read_string |
remove_option(section, option)
Remove the specified option from the specified section. If the section does not exist, raise NoSectionError. If the option existed to be removed, return True; otherwise return False. | python.library.configparser#configparser.ConfigParser.remove_option |
remove_section(section)
Remove the specified section from the configuration. If the section in fact existed, return True. Otherwise return False. | python.library.configparser#configparser.ConfigParser.remove_section |
ConfigParser.SECTCRE
A compiled regular expression used to parse section headers. The default matches [section] to the name "section". Whitespace is considered part of the section name, thus [ larch ] will be read as a section of name " larch ". Override this attribute if that’s unsuitable. For example: >>> impor... | python.library.configparser#configparser.ConfigParser.SECTCRE |
sections()
Return a list of the sections available; the default section is not included in the list. | python.library.configparser#configparser.ConfigParser.sections |
set(section, option, value)
If the given section exists, set the given option to the specified value; otherwise raise NoSectionError. option and value must be strings; if not, TypeError is raised. | python.library.configparser#configparser.ConfigParser.set |
write(fileobject, space_around_delimiters=True)
Write a representation of the configuration to the specified file object, which must be opened in text mode (accepting strings). This representation can be parsed by a future read() call. If space_around_delimiters is true, delimiters between keys and values are surroun... | python.library.configparser#configparser.ConfigParser.write |
exception configparser.DuplicateOptionError
Exception raised by strict parsers if a single option appears twice during reading from a single file, string or dictionary. This catches misspellings and case sensitivity-related errors, e.g. a dictionary may have two keys representing the same case-insensitive configurati... | python.library.configparser#configparser.DuplicateOptionError |
exception configparser.DuplicateSectionError
Exception raised if add_section() is called with the name of a section that is already present or in strict parsers when a section if found more than once in a single input file, string or dictionary. New in version 3.2: Optional source and lineno attributes and arguments... | python.library.configparser#configparser.DuplicateSectionError |
exception configparser.Error
Base class for all other configparser exceptions. | python.library.configparser#configparser.Error |
class configparser.ExtendedInterpolation
An alternative handler for interpolation which implements a more advanced syntax, used for instance in zc.buildout. Extended interpolation is using ${section:option} to denote a value from a foreign section. Interpolation can span multiple levels. For convenience, if the secti... | python.library.configparser#configparser.ExtendedInterpolation |
exception configparser.InterpolationDepthError
Exception raised when string interpolation cannot be completed because the number of iterations exceeds MAX_INTERPOLATION_DEPTH. Subclass of InterpolationError. | python.library.configparser#configparser.InterpolationDepthError |
exception configparser.InterpolationError
Base class for exceptions raised when problems occur performing string interpolation. | python.library.configparser#configparser.InterpolationError |
exception configparser.InterpolationMissingOptionError
Exception raised when an option referenced from a value does not exist. Subclass of InterpolationError. | python.library.configparser#configparser.InterpolationMissingOptionError |
exception configparser.InterpolationSyntaxError
Exception raised when the source text into which substitutions are made does not conform to the required syntax. Subclass of InterpolationError. | python.library.configparser#configparser.InterpolationSyntaxError |
configparser.MAX_INTERPOLATION_DEPTH
The maximum depth for recursive interpolation for get() when the raw parameter is false. This is relevant only when the default interpolation is used. | python.library.configparser#configparser.MAX_INTERPOLATION_DEPTH |
exception configparser.MissingSectionHeaderError
Exception raised when attempting to parse a file which has no section headers. | python.library.configparser#configparser.MissingSectionHeaderError |
exception configparser.NoOptionError
Exception raised when a specified option is not found in the specified section. | python.library.configparser#configparser.NoOptionError |
exception configparser.NoSectionError
Exception raised when a specified section is not found. | python.library.configparser#configparser.NoSectionError |
exception configparser.ParsingError
Exception raised when errors occur attempting to parse a file. Changed in version 3.2: The filename attribute and __init__() argument were renamed to source for consistency. | python.library.configparser#configparser.ParsingError |
class configparser.RawConfigParser(defaults=None, dict_type=dict, allow_no_value=False, *, delimiters=('=', ':'), comment_prefixes=('#', ';'), inline_comment_prefixes=None, strict=True, empty_lines_in_values=True, default_section=configparser.DEFAULTSECT[, interpolation])
Legacy variant of the ConfigParser. It has in... | python.library.configparser#configparser.RawConfigParser |
add_section(section)
Add a section named section to the instance. If a section by the given name already exists, DuplicateSectionError is raised. If the default section name is passed, ValueError is raised. Type of section is not checked which lets users create non-string named sections. This behaviour is unsupported... | python.library.configparser#configparser.RawConfigParser.add_section |
set(section, option, value)
If the given section exists, set the given option to the specified value; otherwise raise NoSectionError. While it is possible to use RawConfigParser (or ConfigParser with raw parameters set to true) for internal storage of non-string values, full functionality (including interpolation and... | python.library.configparser#configparser.RawConfigParser.set |
exception ConnectionAbortedError
A subclass of ConnectionError, raised when a connection attempt is aborted by the peer. Corresponds to errno ECONNABORTED. | python.library.exceptions#ConnectionAbortedError |
exception ConnectionError
A base class for connection-related issues. Subclasses are BrokenPipeError, ConnectionAbortedError, ConnectionRefusedError and ConnectionResetError. | python.library.exceptions#ConnectionError |
exception ConnectionRefusedError
A subclass of ConnectionError, raised when a connection attempt is refused by the peer. Corresponds to errno ECONNREFUSED. | python.library.exceptions#ConnectionRefusedError |
exception ConnectionResetError
A subclass of ConnectionError, raised when a connection is reset by the peer. Corresponds to errno ECONNRESET. | python.library.exceptions#ConnectionResetError |
Built-in Constants A small number of constants live in the built-in namespace. They are:
False
The false value of the bool type. Assignments to False are illegal and raise a SyntaxError.
True
The true value of the bool type. Assignments to True are illegal and raise a SyntaxError.
None
The sole value of... | python.library.constants |
container.__iter__()
Return an iterator object. The object is required to support the iterator protocol described below. If a container supports different types of iteration, additional methods can be provided to specifically request iterators for those iteration types. (An example of an object supporting multiple fo... | python.library.stdtypes#container.__iter__ |
contextlib — Utilities for with-statement contexts Source code: Lib/contextlib.py This module provides utilities for common tasks involving the with statement. For more information see also Context Manager Types and With Statement Context Managers. Utilities Functions and classes provided:
class contextlib.AbstractCo... | python.library.contextlib |
class contextlib.AbstractAsyncContextManager
An abstract base class for classes that implement object.__aenter__() and object.__aexit__(). A default implementation for object.__aenter__() is provided which returns self while object.__aexit__() is an abstract method which by default returns None. See also the definiti... | python.library.contextlib#contextlib.AbstractAsyncContextManager |
class contextlib.AbstractContextManager
An abstract base class for classes that implement object.__enter__() and object.__exit__(). A default implementation for object.__enter__() is provided which returns self while object.__exit__() is an abstract method which by default returns None. See also the definition of Con... | python.library.contextlib#contextlib.AbstractContextManager |
@contextlib.asynccontextmanager
Similar to contextmanager(), but creates an asynchronous context manager. This function is a decorator that can be used to define a factory function for async with statement asynchronous context managers, without needing to create a class or separate __aenter__() and __aexit__() method... | python.library.contextlib#contextlib.asynccontextmanager |
class contextlib.AsyncExitStack
An asynchronous context manager, similar to ExitStack, that supports combining both synchronous and asynchronous context managers, as well as having coroutines for cleanup logic. The close() method is not implemented, aclose() must be used instead.
enter_async_context(cm)
Similar t... | python.library.contextlib#contextlib.AsyncExitStack |
aclose()
Similar to close() but properly handles awaitables. | python.library.contextlib#contextlib.AsyncExitStack.aclose |
enter_async_context(cm)
Similar to enter_context() but expects an asynchronous context manager. | python.library.contextlib#contextlib.AsyncExitStack.enter_async_context |
push_async_callback(callback, /, *args, **kwds)
Similar to callback() but expects a coroutine function. | python.library.contextlib#contextlib.AsyncExitStack.push_async_callback |
push_async_exit(exit)
Similar to push() but expects either an asynchronous context manager or a coroutine function. | python.library.contextlib#contextlib.AsyncExitStack.push_async_exit |
contextlib.closing(thing)
Return a context manager that closes thing upon completion of the block. This is basically equivalent to: from contextlib import contextmanager
@contextmanager
def closing(thing):
try:
yield thing
finally:
thing.close()
And lets you write code like this: from contex... | python.library.contextlib#contextlib.closing |
class contextlib.ContextDecorator
A base class that enables a context manager to also be used as a decorator. Context managers inheriting from ContextDecorator have to implement __enter__ and __exit__ as normal. __exit__ retains its optional exception handling even when used as a decorator. ContextDecorator is used b... | python.library.contextlib#contextlib.ContextDecorator |
@contextlib.contextmanager
This function is a decorator that can be used to define a factory function for with statement context managers, without needing to create a class or separate __enter__() and __exit__() methods. While many objects natively support use in with statements, sometimes a resource needs to be mana... | python.library.contextlib#contextlib.contextmanager |
class contextlib.ExitStack
A context manager that is designed to make it easy to programmatically combine other context managers and cleanup functions, especially those that are optional or otherwise driven by input data. For example, a set of files may easily be handled in a single with statement as follows: with Ex... | python.library.contextlib#contextlib.ExitStack |
callback(callback, /, *args, **kwds)
Accepts an arbitrary callback function and arguments and adds it to the callback stack. Unlike the other methods, callbacks added this way cannot suppress exceptions (as they are never passed the exception details). The passed in callback is returned from the function, allowing th... | python.library.contextlib#contextlib.ExitStack.callback |
close()
Immediately unwinds the callback stack, invoking callbacks in the reverse order of registration. For any context managers and exit callbacks registered, the arguments passed in will indicate that no exception occurred. | python.library.contextlib#contextlib.ExitStack.close |
enter_context(cm)
Enters a new context manager and adds its __exit__() method to the callback stack. The return value is the result of the context manager’s own __enter__() method. These context managers may suppress exceptions just as they normally would if used directly as part of a with statement. | python.library.contextlib#contextlib.ExitStack.enter_context |
pop_all()
Transfers the callback stack to a fresh ExitStack instance and returns it. No callbacks are invoked by this operation - instead, they will now be invoked when the new stack is closed (either explicitly or implicitly at the end of a with statement). For example, a group of files can be opened as an “all or n... | python.library.contextlib#contextlib.ExitStack.pop_all |
push(exit)
Adds a context manager’s __exit__() method to the callback stack. As __enter__ is not invoked, this method can be used to cover part of an __enter__() implementation with a context manager’s own __exit__() method. If passed an object that is not a context manager, this method assumes it is a callback with ... | python.library.contextlib#contextlib.ExitStack.push |
contextlib.nullcontext(enter_result=None)
Return a context manager that returns enter_result from __enter__, but otherwise does nothing. It is intended to be used as a stand-in for an optional context manager, for example: def myfunction(arg, ignore_exceptions=False):
if ignore_exceptions:
# Use suppress ... | python.library.contextlib#contextlib.nullcontext |
contextlib.redirect_stderr(new_target)
Similar to redirect_stdout() but redirecting sys.stderr to another file or file-like object. This context manager is reentrant. New in version 3.5. | python.library.contextlib#contextlib.redirect_stderr |
contextlib.redirect_stdout(new_target)
Context manager for temporarily redirecting sys.stdout to another file or file-like object. This tool adds flexibility to existing functions or classes whose output is hardwired to stdout. For example, the output of help() normally is sent to sys.stdout. You can capture that out... | python.library.contextlib#contextlib.redirect_stdout |
contextlib.suppress(*exceptions)
Return a context manager that suppresses any of the specified exceptions if they occur in the body of a with statement and then resumes execution with the first statement following the end of the with statement. As with any other mechanism that completely suppresses exceptions, this c... | python.library.contextlib#contextlib.suppress |
contextmanager.__enter__()
Enter the runtime context and return either this object or another object related to the runtime context. The value returned by this method is bound to the identifier in the as clause of with statements using this context manager. An example of a context manager that returns itself is a fil... | python.library.stdtypes#contextmanager.__enter__ |
contextmanager.__exit__(exc_type, exc_val, exc_tb)
Exit the runtime context and return a Boolean flag indicating if any exception that occurred should be suppressed. If an exception occurred while executing the body of the with statement, the arguments contain the exception type, value and traceback information. Othe... | python.library.stdtypes#contextmanager.__exit__ |
contextvars — Context Variables This module provides APIs to manage, store, and access context-local state. The ContextVar class is used to declare and work with Context Variables. The copy_context() function and the Context class should be used to manage the current context in asynchronous frameworks. Context managers... | python.library.contextvars |
class contextvars.Context
A mapping of ContextVars to their values. Context() creates an empty context with no values in it. To get a copy of the current context use the copy_context() function. Context implements the collections.abc.Mapping interface.
run(callable, *args, **kwargs)
Execute callable(*args, **kwar... | python.library.contextvars#contextvars.Context |
copy()
Return a shallow copy of the context object. | python.library.contextvars#contextvars.Context.copy |
get(var[, default])
Return the value for var if var has the value in the context object. Return default otherwise. If default is not given, return None. | python.library.contextvars#contextvars.Context.get |
items()
Return a list of 2-tuples containing all variables and their values in the context object. | python.library.contextvars#contextvars.Context.items |
keys()
Return a list of all variables in the context object. | python.library.contextvars#contextvars.Context.keys |
run(callable, *args, **kwargs)
Execute callable(*args, **kwargs) code in the context object the run method is called on. Return the result of the execution or propagate an exception if one occurred. Any changes to any context variables that callable makes will be contained in the context object: var = ContextVar('var... | python.library.contextvars#contextvars.Context.run |
values()
Return a list of all variables’ values in the context object. | python.library.contextvars#contextvars.Context.values |
class contextvars.ContextVar(name[, *, default])
This class is used to declare a new Context Variable, e.g.: var: ContextVar[int] = ContextVar('var', default=42)
The required name parameter is used for introspection and debug purposes. The optional keyword-only default parameter is returned by ContextVar.get() when ... | python.library.contextvars#contextvars.ContextVar |
get([default])
Return a value for the context variable for the current context. If there is no value for the variable in the current context, the method will: return the value of the default argument of the method, if provided; or return the default value for the context variable, if it was created with one; or rais... | python.library.contextvars#contextvars.ContextVar.get |
name
The name of the variable. This is a read-only property. New in version 3.7.1. | python.library.contextvars#contextvars.ContextVar.name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.