diff options
Diffstat (limited to 'Doc/howto/functional.rst')
-rw-r--r-- | Doc/howto/functional.rst | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst index ebbb229..b621a84 100644 --- a/Doc/howto/functional.rst +++ b/Doc/howto/functional.rst @@ -292,13 +292,14 @@ ordering of the objects in the dictionary. Applying :func:`iter` to a dictionary always loops over the keys, but dictionaries have methods that return other iterators. If you want to iterate over values or key/value pairs, you can explicitly call the -:meth:`~dict.values` or :meth:`~dict.items` methods to get an appropriate iterator. +:meth:`~dict.values` or :meth:`~dict.items` methods to get an appropriate +iterator. The :func:`dict` constructor can accept an iterator that returns a finite stream of ``(key, value)`` tuples: >>> L = [('Italy', 'Rome'), ('France', 'Paris'), ('US', 'Washington DC')] - >>> dict(iter(L)) + >>> dict(iter(L)) #doctest: +SKIP {'Italy': 'Rome', 'US': 'Washington DC', 'France': 'Paris'} Files also support iteration by calling the :meth:`~io.TextIOBase.readline` |