diff --git a/special-method-names.html b/special-method-names.html index 43b9c1b..009b126 100644 --- a/special-method-names.html +++ b/special-method-names.html @@ -90,6 +90,13 @@ h3:before{counter-increment:h3;content:'B.' counter(h2) '.' counter(h3) '. '}
__reversed__() method is uncommon. It takes an existing sequence and returns an iterator that yields the items in the sequence in reverse order, from last to first.
+As you saw in the Iterators chapter, a for loop can act on an iterator. In this loop:
+
+
for x in seq:
+ print(x)
+
+Python 3 will call seq.__iter__() to create an iterator, then call the __next__() method on that iterator to get each value of x. When the __next__() method raises a StopIteration exception, the for loop ends gracefully.
+