diff options
| -rw-r--r-- | Doc/howto/functional.rst | 5 | ||||
| -rw-r--r-- | Doc/library/functions.rst | 25 | ||||
| -rw-r--r-- | Lib/test/test_runpy.py | 4 | ||||
| -rw-r--r-- | Lib/test/test_timeit.py | 1 |
4 files changed, 14 insertions, 21 deletions
diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst index b621a84..ebbb229 100644 --- a/Doc/howto/functional.rst +++ b/Doc/howto/functional.rst @@ -292,14 +292,13 @@ 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)) #doctest: +SKIP + >>> dict(iter(L)) {'Italy': 'Rome', 'US': 'Washington DC', 'France': 'Paris'} Files also support iteration by calling the :meth:`~io.TextIOBase.readline` diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index f782655..173baf4 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -122,8 +122,6 @@ are always available. They are listed here in alphabetical order. Without an argument, an array of size 0 is created. - See also :ref:`binaryseq` and :ref:`typebytearray`. - .. _func-bytes: .. function:: bytes([source[, encoding[, errors]]]) @@ -137,8 +135,6 @@ are always available. They are listed here in alphabetical order. Bytes objects can also be created with literals, see :ref:`strings`. - See also :ref:`binaryseq`, :ref:`typebytes`, and :ref:`bytes-methods`. - .. function:: callable(object) @@ -692,8 +688,6 @@ are always available. They are listed here in alphabetical order. *sentinel*, :exc:`StopIteration` will be raised, otherwise the value will be returned. - See also :ref:`typeiter`. - One useful application of the second form of :func:`iter` is to read lines of a file until a certain line is reached. The following example reads a file until the :meth:`readline` method returns an empty string:: @@ -714,7 +708,7 @@ are always available. They are listed here in alphabetical order. :noindex: Rather than being a function, :class:`list` is actually a mutable - sequence type, as documented in :ref:`typesseq-list` and :ref:`typesseq`. + sequence type, as documented in :ref:`typesseq`. .. function:: locals() @@ -1088,7 +1082,7 @@ are always available. They are listed here in alphabetical order. :noindex: Rather than being a function, :class:`range` is actually an immutable - sequence type, as documented in :ref:`typesseq-range` and :ref:`typesseq`. + sequence type, as documented in :ref:`typesseq`. .. function:: repr(object) @@ -1213,8 +1207,7 @@ are always available. They are listed here in alphabetical order. .. function:: str(object='') str(object[, encoding[, errors]]) - Return a :ref:`string <textseq>` version of an object, using one of the - following modes: + Return a string version of an object, using one of the following modes: If *encoding* and/or *errors* are given, :func:`str` will decode the *object* which can either be a byte string or a character buffer using @@ -1237,9 +1230,11 @@ are always available. They are listed here in alphabetical order. Objects can specify what ``str(object)`` returns by defining a :meth:`__str__` special method. - For more information on strings and string methods, see the :ref:`textseq` - section. To output formatted strings, see the :ref:`string-formatting` - section. In addition, see the :ref:`stringservices` section. + For more information on strings see :ref:`typesseq` which describes sequence + functionality (strings are sequences), and also the string-specific methods + described in the :ref:`string-methods` section. To output formatted strings, + see the :ref:`string-formatting` section. In addition see the + :ref:`stringservices` section. .. function:: sum(iterable[, start]) @@ -1316,7 +1311,7 @@ are always available. They are listed here in alphabetical order. :noindex: Rather than being a function, :class:`tuple` is actually an immutable - sequence type, as documented in :ref:`typesseq-tuple` and :ref:`typesseq`. + sequence type, as documented in :ref:`typesseq`. .. function:: type(object) @@ -1349,8 +1344,6 @@ are always available. They are listed here in alphabetical order. ... >>> X = type('X', (object,), dict(a=1)) - See also :ref:`bltin-type-objects`. - .. function:: vars([object]) diff --git a/Lib/test/test_runpy.py b/Lib/test/test_runpy.py index 8b443f6..fefefc4 100644 --- a/Lib/test/test_runpy.py +++ b/Lib/test/test_runpy.py @@ -565,10 +565,10 @@ class RunPathTestCase(unittest.TestCase, CodeExecutionMixin): with open(filename, 'w', encoding='latin1') as f: f.write(""" #coding:latin1 -"non-ASCII: h\xe9" +s = "non-ASCII: h\xe9" """) result = run_path(filename) - self.assertEqual(result['__doc__'], "non-ASCII: h\xe9") + self.assertEqual(result['s'], "non-ASCII: h\xe9") def test_main(): diff --git a/Lib/test/test_timeit.py b/Lib/test/test_timeit.py index eb3b1a1..625fb8d 100644 --- a/Lib/test/test_timeit.py +++ b/Lib/test/test_timeit.py @@ -250,6 +250,7 @@ class TestTimeit(unittest.TestCase): s = self.run_main(seconds_per_increment=60.0, switches=['-r-5']) self.assertEqual(s, "10 loops, best of 1: 60 sec per loop\n") + @unittest.skipIf(sys.flags.optimize >= 2, "need __doc__") def test_main_help(self): s = self.run_main(switches=['-h']) # Note: It's not clear that the trailing space was intended as part of |
