Summary

In this chapter, we looked at different ways to use NamedTuple objects to implement more complex data structures. The essential features of a NamedTuple are a good fit with functional design. They can be created with a creation function and accessed by position as well as name.

We looked at how to use immutable NamedTuple objects instead of stateful object definitions. The core technique for replacing state changes is to wrap objects in larger tuple objects.

We also looked at ways to handle multiple data types in Python. For most arithmetic operations, Python's internal method dispatch locates proper implementations. To work with collections, however, we might want to handle iterators and sequences slightly differently.

In the next two chapters, we'll look at the itertools module. This library module provides a number of functions that help us work with iterators in sophisticated ways. Many of these tools are examples of higher-order functions. They can help make a functional design stay succinct and expressive.

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

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