ABSTRACT

The functional style of programming is one that leverages the ability to create functions in nearly extreme ways. In addition to making functions that compute numeric, string, and list values, a function can test what kind of arguments it is given and change what it returns accordingly. This chapter shows how Python functions can work with multiple arguments and even substitute for missing arguments. The functional style encourages programmers to write functions from other functions: some functions are built in to Python, and these can be used to write other functions. There are even functions that have, as inputs, other functions! This abstract way of thinking moves the programmer up to higher layers, so to speak, on the pyramid of software automation. Whereas low-level data processing works with numbers, higher-level computing approaches symbolic reasoning, where operations seem to transform ideas. Fortunately, the material in this chapter is not so abstract: the techniques are mainstream Python language concepts and turn out to be quite practical.