Skip to Content
Advanced Python 3 Programming Techniques
book

Advanced Python 3 Programming Techniques

by Mark Summerfield
February 2009
Intermediate to advanced
68 pages
1h 51m
English
Addison-Wesley Professional
Content preview from Advanced Python 3 Programming Techniques

Chapter 5. Local and Recursive Functions

It is often useful to have one or more small helper functions inside another function. Python allows this without formality—we simply define the functions we need inside the definition of an existing function. Such functions are often called nested functions or local functions.

One common use case for local functions is when we want to use recursion. In these cases, the enclosing function is called, sets things up, and then makes the first call to a local recursive function. Recursive functions (or methods) are ones that call themselves. Structurally, all directly recursive functions can be seen as having two cases: the base case and the recursive case. The base case is used to stop the recursion. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Network Programming Techniques

Python Network Programming Techniques

Marcel Neidinger
Scientific Computing with Python 3

Scientific Computing with Python 3

Claus Führer, Claus Fuhrer, Jan Erik Solem, Olivier Verdier

Publisher Resources

ISBN: 9780321637727