9.5 Exercises
You’ve probably used many of the basic built-in functions before now. We covered several of them, but didn’t go into a great deal of detail. Play with enumerate, zip, reversed, any, and all until you know you’ll remember to use them when they are the right tool for the job. The enumerate function is especially important because not using it results in some pretty ugly while statements.
Also explore some applications that pass functions around as callable objects, as well as using the __call__() method to make your own objects callable. You can get the same effect by attaching attributes to functions or by creating a __call__() method on an object. In which case would you use one syntax, and when would it be more suitable to use the other?
The relationship between arguments, keyword arguments, variable arguments, and variable keyword arguments can be a bit confusing. We saw how painfully they can interact when we covered multiple...