July 2009
Intermediate to advanced
744 pages
20h 2m
English
Substantial programs are broken up into functions for better modularity and ease of maintenance. Python makes it easy to define functions but also incorporates a surprising number of features from functional programming languages. This chapter describes functions, scoping rules, closures, decorators, generators, coroutines, and other functional programming features. In addition, list comprehensions and generator expressions are described—both of which are powerful tools for declarative-style programming and data processing.
Functions are defined with the def statement:
![]()
The body of a function ...
Read now
Unlock full access