Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5c3283e

Browse files
committed
Merge __next__ method link fixes with 3.3.
2 parents 9054055 + 1dd7c30 commit 5c3283e

10 files changed

Lines changed: 61 additions & 56 deletions

File tree

Doc/glossary.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ Glossary
365365

366366
iterator
367367
An object representing a stream of data. Repeated calls to the iterator's
368-
:meth:`__next__` method (or passing it to the built-in function
368+
:meth:`~iterator.__next__` method (or passing it to the built-in function
369369
:func:`next`) return successive items in the stream. When no more data
370370
are available a :exc:`StopIteration` exception is raised instead. At this
371371
point, the iterator object is exhausted and any further calls to its

Doc/library/concurrent.futures.rst

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@ Executor Objects
4242

4343
Equivalent to ``map(func, *iterables)`` except *func* is executed
4444
asynchronously and several calls to *func* may be made concurrently. The
45-
returned iterator raises a :exc:`TimeoutError` if :meth:`__next__()` is
46-
called and the result isn't available after *timeout* seconds from the
47-
original call to :meth:`Executor.map`. *timeout* can be an int or a
48-
float. If *timeout* is not specified or ``None``, there is no limit to
49-
the wait time. If a call raises an exception, then that exception will
50-
be raised when its value is retrieved from the iterator.
45+
returned iterator raises a :exc:`TimeoutError` if
46+
:meth:`~iterator.__next__` is called and the result isn't available
47+
after *timeout* seconds from the original call to :meth:`Executor.map`.
48+
*timeout* can be an int or a float. If *timeout* is not specified or
49+
``None``, there is no limit to the wait time. If a call raises an
50+
exception, then that exception will be raised when its value is
51+
retrieved from the iterator.
5152

5253
.. method:: shutdown(wait=True)
5354

@@ -364,10 +365,11 @@ Module Functions
364365
different :class:`Executor` instances) given by *fs* that yields futures as
365366
they complete (finished or were cancelled). Any futures that completed
366367
before :func:`as_completed` is called will be yielded first. The returned
367-
iterator raises a :exc:`TimeoutError` if :meth:`__next__` is called and the
368-
result isn't available after *timeout* seconds from the original call to
369-
:func:`as_completed`. *timeout* can be an int or float. If *timeout* is not
370-
specified or ``None``, there is no limit to the wait time.
368+
iterator raises a :exc:`TimeoutError` if :meth:`~iterator.__next__` is
369+
called and the result isn't available after *timeout* seconds from the
370+
original call to :func:`as_completed`. *timeout* can be an int or float.
371+
If *timeout* is not specified or ``None``, there is no limit to the wait
372+
time.
371373

372374

373375
.. seealso::

Doc/library/dis.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -660,10 +660,10 @@ the more significant byte last.
660660

661661
.. opcode:: FOR_ITER (delta)
662662

663-
``TOS`` is an :term:`iterator`. Call its :meth:`__next__` method. If this
664-
yields a new value, push it on the stack (leaving the iterator below it). If
665-
the iterator indicates it is exhausted ``TOS`` is popped, and the byte code
666-
counter is incremented by *delta*.
663+
``TOS`` is an :term:`iterator`. Call its :meth:`~iterator.__next__` method.
664+
If this yields a new value, push it on the stack (leaving the iterator below
665+
it). If the iterator indicates it is exhausted ``TOS`` is popped, and the
666+
byte code counter is incremented by *delta*.
667667

668668

669669
.. opcode:: LOAD_GLOBAL (namei)

Doc/library/exceptions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ The following exceptions are the exceptions that are usually raised.
275275
.. exception:: StopIteration
276276

277277
Raised by built-in function :func:`next` and an :term:`iterator`\'s
278-
:meth:`__next__` method to signal that there are no further items to be
279-
produced by the iterator.
278+
:meth:`~iterator.__next__` method to signal that there are no further
279+
items produced by the iterator.
280280

281281
The exception object has a single attribute :attr:`value`, which is
282282
given as an argument when constructing the exception, and defaults

Doc/library/functions.rst

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,10 @@ are always available. They are listed here in alphabetical order.
352352
.. function:: enumerate(iterable, start=0)
353353

354354
Return an enumerate object. *iterable* must be a sequence, an
355-
:term:`iterator`, or some other object which supports iteration. The
356-
:meth:`__next__` method of the iterator returned by :func:`enumerate` returns a
357-
tuple containing a count (from *start* which defaults to 0) and the
358-
values obtained from iterating over *iterable*.
355+
:term:`iterator`, or some other object which supports iteration.
356+
The :meth:`~iterator.__next__` method of the iterator returned by
357+
:func:`enumerate` returns a tuple containing a count (from *start* which
358+
defaults to 0) and the values obtained from iterating over *iterable*.
359359

360360
>>> seasons = ['Spring', 'Summer', 'Fall', 'Winter']
361361
>>> list(enumerate(seasons))
@@ -687,9 +687,10 @@ are always available. They are listed here in alphabetical order.
687687
starting at ``0``). If it does not support either of those protocols,
688688
:exc:`TypeError` is raised. If the second argument, *sentinel*, is given,
689689
then *object* must be a callable object. The iterator created in this case
690-
will call *object* with no arguments for each call to its :meth:`__next__`
691-
method; if the value returned is equal to *sentinel*, :exc:`StopIteration`
692-
will be raised, otherwise the value will be returned.
690+
will call *object* with no arguments for each call to its
691+
:meth:`~iterator.__next__` method; if the value returned is equal to
692+
*sentinel*, :exc:`StopIteration` will be raised, otherwise the value will
693+
be returned.
693694

694695
See also :ref:`typeiter`.
695696

@@ -785,9 +786,9 @@ are always available. They are listed here in alphabetical order.
785786

786787
.. function:: next(iterator[, default])
787788

788-
Retrieve the next item from the *iterator* by calling its :meth:`__next__`
789-
method. If *default* is given, it is returned if the iterator is exhausted,
790-
otherwise :exc:`StopIteration` is raised.
789+
Retrieve the next item from the *iterator* by calling its
790+
:meth:`~iterator.__next__` method. If *default* is given, it is returned
791+
if the iterator is exhausted, otherwise :exc:`StopIteration` is raised.
791792

792793

793794
.. function:: object()

Doc/library/stdtypes.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -779,9 +779,9 @@ specific sequence types, dictionaries, and other more specialized forms. The
779779
specific types are not important beyond their implementation of the iterator
780780
protocol.
781781

782-
Once an iterator's :meth:`__next__` method raises :exc:`StopIteration`, it must
783-
continue to do so on subsequent calls. Implementations that do not obey this
784-
property are deemed broken.
782+
Once an iterator's :meth:`~iterator.__next__` method raises
783+
:exc:`StopIteration`, it must continue to do so on subsequent calls.
784+
Implementations that do not obey this property are deemed broken.
785785

786786

787787
.. _generator-types:
@@ -792,7 +792,8 @@ Generator Types
792792
Python's :term:`generator`\s provide a convenient way to implement the iterator
793793
protocol. If a container object's :meth:`__iter__` method is implemented as a
794794
generator, it will automatically return an iterator object (technically, a
795-
generator object) supplying the :meth:`__iter__` and :meth:`__next__` methods.
795+
generator object) supplying the :meth:`__iter__` and :meth:`~generator.__next__`
796+
methods.
796797
More information about generators can be found in :ref:`the documentation for
797798
the yield expression <yieldexpr>`.
798799

Doc/reference/datamodel.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -600,9 +600,9 @@ Callable types
600600
A function or method which uses the :keyword:`yield` statement (see section
601601
:ref:`yield`) is called a :dfn:`generator function`. Such a function, when
602602
called, always returns an iterator object which can be used to execute the
603-
body of the function: calling the iterator's :meth:`__next__` method will
604-
cause the function to execute until it provides a value using the
605-
:keyword:`yield` statement. When the function executes a
603+
body of the function: calling the iterator's :meth:`iterator__next__`
604+
method will cause the function to execute until it provides a value
605+
using the :keyword:`yield` statement. When the function executes a
606606
:keyword:`return` statement or falls off the end, a :exc:`StopIteration`
607607
exception is raised and the iterator will have reached the end of the set of
608608
values to be returned.

Doc/reference/expressions.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,13 @@ for comprehensions, except that it is enclosed in parentheses instead of
294294
brackets or curly braces.
295295

296296
Variables used in the generator expression are evaluated lazily when the
297-
:meth:`__next__` method is called for generator object (in the same fashion as
298-
normal generators). However, the leftmost :keyword:`for` clause is immediately
299-
evaluated, so that an error produced by it can be seen before any other possible
300-
error in the code that handles the generator expression. Subsequent
301-
:keyword:`for` clauses cannot be evaluated immediately since they may depend on
302-
the previous :keyword:`for` loop. For example: ``(x*y for x in range(10) for y
303-
in bar(x))``.
297+
:meth:`~generator.__next__` method is called for generator object (in the same
298+
fashion as normal generators). However, the leftmost :keyword:`for` clause is
299+
immediately evaluated, so that an error produced by it can be seen before any
300+
other possible error in the code that handles the generator expression.
301+
Subsequent :keyword:`for` clauses cannot be evaluated immediately since they
302+
may depend on the previous :keyword:`for` loop. For example: ``(x*y for x in
303+
range(10) for y in bar(x))``.
304304

305305
The parentheses can be omitted on calls with only one argument. See section
306306
:ref:`calls` for the detail.
@@ -394,10 +394,11 @@ is already executing raises a :exc:`ValueError` exception.
394394

395395
Starts the execution of a generator function or resumes it at the last
396396
executed :keyword:`yield` expression. When a generator function is resumed
397-
with a :meth:`__next__` method, the current :keyword:`yield` expression
398-
always evaluates to :const:`None`. The execution then continues to the next
399-
:keyword:`yield` expression, where the generator is suspended again, and the
400-
value of the :token:`expression_list` is returned to :meth:`next`'s caller.
397+
with a :meth:`~generator.__next__` method, the current :keyword:`yield`
398+
expression always evaluates to :const:`None`. The execution then continues
399+
to the next :keyword:`yield` expression, where the generator is suspended
400+
again, and the value of the :token:`expression_list` is returned to
401+
:meth:`next`'s caller.
401402
If the generator exits without yielding another value, a :exc:`StopIteration`
402403
exception is raised.
403404

Doc/tutorial/classes.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -737,11 +737,11 @@ using a :keyword:`for` statement::
737737
This style of access is clear, concise, and convenient. The use of iterators
738738
pervades and unifies Python. Behind the scenes, the :keyword:`for` statement
739739
calls :func:`iter` on the container object. The function returns an iterator
740-
object that defines the method :meth:`__next__` which accesses elements in the
741-
container one at a time. When there are no more elements, :meth:`__next__`
742-
raises a :exc:`StopIteration` exception which tells the :keyword:`for` loop to
743-
terminate. You can call the :meth:`__next__` method using the :func:`next`
744-
built-in function; this example shows how it all works::
740+
object that defines the method :meth:`~iterator.__next__` which accesses
741+
elements in the container one at a time. When there are no more elements,
742+
:meth:`__next__` raises a :exc:`StopIteration` exception which tells the
743+
:keyword:`for` loop to terminate. You can call the :meth:`__next__` method
744+
using the :func:`next` built-in function; this example shows how it all works::
745745

746746
>>> s = 'abc'
747747
>>> it = iter(s)
@@ -761,8 +761,8 @@ built-in function; this example shows how it all works::
761761

762762
Having seen the mechanics behind the iterator protocol, it is easy to add
763763
iterator behavior to your classes. Define an :meth:`__iter__` method which
764-
returns an object with a :meth:`__next__` method. If the class defines
765-
:meth:`__next__`, then :meth:`__iter__` can just return ``self``::
764+
returns an object with a :meth:`~iterator.__next__` method. If the class
765+
defines :meth:`__next__`, then :meth:`__iter__` can just return ``self``::
766766

767767
class Reverse:
768768
"""Iterator for looping over a sequence backwards."""
@@ -819,8 +819,8 @@ easy to create::
819819

820820
Anything that can be done with generators can also be done with class based
821821
iterators as described in the previous section. What makes generators so
822-
compact is that the :meth:`__iter__` and :meth:`__next__` methods are created
823-
automatically.
822+
compact is that the :meth:`__iter__` and :meth:`~generator.__next__` methods
823+
are created automatically.
824824

825825
Another key feature is that the local variables and execution state are
826826
automatically saved between calls. This made the function easier to write and

Doc/whatsnew/3.0.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ Operators And Special Methods
771771
respectively).
772772

773773
* :pep:`3114`: the standard :meth:`next` method has been renamed to
774-
:meth:`__next__`.
774+
:meth:`~iterator.__next__`.
775775

776776
* The :meth:`__oct__` and :meth:`__hex__` special methods are removed
777777
-- :func:`oct` and :func:`hex` use :meth:`__index__` now to convert
@@ -807,7 +807,7 @@ Builtins
807807
To get the old behavior of :func:`input`, use ``eval(input())``.
808808

809809
* A new built-in function :func:`next` was added to call the
810-
:meth:`__next__` method on an object.
810+
:meth:`~iterator.__next__` method on an object.
811811

812812
* The :func:`round` function rounding strategy and return type have
813813
changed. Exact halfway cases are now rounded to the nearest even

0 commit comments

Comments
 (0)