Chapter 6. Functions and Functional Programming

Most substantial programs are broken up into functions for better modularity and ease of maintenance. Python makes it easy to define functions, but borrows a number of ideas from functional programming languages that simplify certain tasks. This chapter describes functions, anonymous functions, and functional programming features, as well as the eval() and execfile() functions and the exec statement. It also describes list comprehensions, a powerful list-construction technique.

Get Python Essential Reference, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.