bpo-21767: explicitly mention abc support in functools.singledispatch docs (#17171)

This commit is contained in:
Batuhan Taşkaya 2019-11-19 11:16:46 +03:00 committed by Łukasz Langa
parent 9960230f76
commit 24555ce2f9
2 changed files with 15 additions and 0 deletions

View File

@ -423,6 +423,20 @@ The :mod:`functools` module defines the following functions:
for the base ``object`` type, which means it is used if no better
implementation is found.
If an implementation registered to :term:`abstract base class`, virtual
subclasses will be dispatched to that implementation::
>>> from collections.abc import Mapping
>>> @fun.register
... def _(arg: Mapping, verbose=False):
... if verbose:
... print("Keys & Values")
... for key, value in arg.items():
... print(key, "=>", value)
...
>>> fun({"a": "b"})
a => b
To check which implementation will the generic function choose for
a given type, use the ``dispatch()`` attribute::

View File

@ -0,0 +1 @@
Explicitly mention abc support in functools.singledispatch