Software Design by Example in Python 8: Functions and Closures
I didn’t initially plan to write Chapter 8: Functions and Closures, but the puzzled looks on my learners’ faces the first few times I tried to teach decorators convinced me it was necessary. If Python’s decorators treated their first argument specially in the way that methods do, multi-argument decorators would be simpler to write and a lot simpler to teach. Since they don’t, this chapter spends 1800 words on dynamic versus lexical scoping, eager versus lazy evaluation, closures, lambda expressions, and a handful of other ideas people need when they’re trying to debug Python’s more advanced features.
Terms defined: anonymous function, call stack, closure, dynamic scoping, eager evaluation, extensibility, lambda expression, lazy evaluation, lexical scoping, name collision, stack frame, variable capture.