diff options
Diffstat (limited to 'Doc/library/operator.rst')
-rw-r--r-- | Doc/library/operator.rst | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Doc/library/operator.rst b/Doc/library/operator.rst index de7a542..d01d33a 100644 --- a/Doc/library/operator.rst +++ b/Doc/library/operator.rst @@ -11,6 +11,9 @@ import operator from operator import itemgetter, iadd +**Source code:** :source:`Lib/operator.py` + +-------------- The :mod:`operator` module exports a set of efficient functions corresponding to the intrinsic operators of Python. For example, ``operator.add(x, y)`` is @@ -235,6 +238,14 @@ their character equivalents. .. XXX: find a better, readable, example +.. function:: length_hint(obj, default=0) + + Return an estimated length for the object *o*. First trying to return its + actual length, then an estimate using :meth:`object.__length_hint__`, and + finally returning the default value. + + .. versionadded:: 3.4 + The :mod:`operator` module also defines tools for generalized attribute and item lookups. These are useful for making fast field extractors as arguments for :func:`map`, :func:`sorted`, :meth:`itertools.groupby`, or other functions that |