Some additional abstractions

We'll look at some other interesting ABC classes that are less widely extended. It's not that these abstractions are less widely used: it's more that the concrete implementations rarely need extensions or revisions.

We'll look at the iterator, which is defined by collections.abc.Iterator. We'll also look at the unrelated concept of a context manager. This isn't defined with the same formality as other ABC classes. We'll look at this in detail in Chapter 6Using Callables and Contexts.

In many cases, we'll create iterators using generator functions and the yield statement. We'll use an explicit type hint of typing.Iterator for these functions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset