diff options
Diffstat (limited to 'Doc/library/functions.rst')
-rw-r--r-- | Doc/library/functions.rst | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index dab83e1..c7e689d 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -41,7 +41,7 @@ available. They are listed here in alphabetical order. top-level package (the name up till the first dot) is returned, *not* the module named by *name*. However, when a non-empty *fromlist* argument is given, the module named by *name* is returned. This is done for - compatibility with the bytecode generated for the different kinds of import + compatibility with the :term:`bytecode` generated for the different kinds of import statement; when using ``import spam.ham.eggs``, the top-level package :mod:`spam` must be placed in the importing namespace, but when using ``from spam.ham import eggs``, the ``spam.ham`` subpackage must be used to find the @@ -317,7 +317,7 @@ available. They are listed here in alphabetical order. .. function:: enumerate(iterable) - Return an enumerate object. *iterable* must be a sequence, an iterator, or some + Return an enumerate object. *iterable* must be a sequence, an :term:`iterator`, or some other object which supports iteration. The :meth:`__next__` method of the iterator returned by :func:`enumerate` returns a tuple containing a count (from zero) and the corresponding value obtained from iterating over *iterable*. @@ -340,7 +340,7 @@ available. They are listed here in alphabetical order. The *expression* argument is parsed and evaluated as a Python expression (technically speaking, a condition list) using the *globals* and *locals* - dictionaries as global and local name space. If the *globals* dictionary is + dictionaries as global and local namespace. If the *globals* dictionary is present and lacks '__builtins__', the current globals are copied into *globals* before *expression* is parsed. This means that *expression* normally has full access to the standard :mod:`__builtin__` module and restricted environments are @@ -408,10 +408,9 @@ available. They are listed here in alphabetical order. Construct an iterator from those elements of *iterable* for which *function* returns true. *iterable* may be either a sequence, a container which - supports iteration, or an iterator, If *iterable* is a string or a tuple, the - result also has that type; otherwise it is always a list. If *function* is - ``None``, the identity function is assumed, that is, all elements of - *iterable* that are false are removed. + supports iteration, or an iterator. If *function* is ``None``, the identity + function is assumed, that is, all elements of *iterable* that are false are + removed. Note that ``filter(function, iterable)`` is equivalent to the generator expression ``(item for item in iterable if function(item))`` if function is @@ -543,15 +542,15 @@ available. They are listed here in alphabetical order. .. function:: int([x[, radix]]) Convert a string or number to an integer. If the argument is a string, it - must contain a possibly signed number of arbitrary size, - possibly embedded in whitespace. The *radix* parameter gives the base for the - conversion and may be any integer in the range [2, 36], or zero. If *radix* is - zero, the interpretation is the same as for integer literals. If *radix* is - specified and *x* is not a string, :exc:`TypeError` is raised. Otherwise, the - argument may be another integer, a floating point number or any other object - that has an :meth:`__int__` method. Conversion - of floating point numbers to integers truncates (towards zero). If no - arguments are given, returns ``0``. + must contain a possibly signed number of arbitrary size, possibly embedded in + whitespace. The *radix* parameter gives the base for the conversion (which + is 10 by default) and may be any integer in the range [2, 36], or zero. If + *radix* is zero, the interpretation is the same as for integer literals. If + *radix* is specified and *x* is not a string, :exc:`TypeError` is raised. + Otherwise, the argument may be another integer, a floating point number or + any other object that has an :meth:`__int__` method. Conversion of floating + point numbers to integers truncates (towards zero). If no arguments are + given, returns ``0``. The integer type is described in :ref:`typesnumeric`. @@ -577,7 +576,7 @@ available. They are listed here in alphabetical order. .. function:: iter(o[, sentinel]) - Return an iterator object. The first argument is interpreted very differently + Return an :term:`iterator` object. The first argument is interpreted very differently depending on the presence of the second argument. Without a second argument, *o* must be a collection object which supports the iteration protocol (the :meth:`__iter__` method), or it must support the sequence protocol (the @@ -857,9 +856,9 @@ available. They are listed here in alphabetical order. .. function:: reversed(seq) - Return a reverse iterator. *seq* must be an object which supports the sequence - protocol (the :meth:`__len__` method and the :meth:`__getitem__` method with - integer arguments starting at ``0``). + Return a reverse :term:`iterator`. *seq* must be an object which supports + the sequence protocol (the :meth:`__len__` method and the :meth:`__getitem__` + method with integer arguments starting at ``0``). .. function:: round(x[, n]) |