Real Python Podcast Episode #124 Title Artwork

Episode 124: Exploring Recursion in Python With Al Sweigart

The Real Python Podcast

Sep 09, 2022 1h 20m

Have you wanted to understand recursion and how to use it in Python? Are you familiar with the call stack and how it relates to tracebacks? This week on the show, Al Sweigart talks about his new book, “The Recursive Book of Recursion.”

Recursion is one of those concepts held as a tenet of high-level computer science priesthood. Al explains the fundamentals of writing recursive functions and a critical missing piece in understanding how they operate, the call stack. After completing his research, he concluded that it’s a technique that you should understand but rarely use.

He also shares the few cases where recursion is an appropriate solution. Along the way, we talk about directed acyclic graphs, solving mazes, exploring file trees, and creating fractal images.

Topics:

  • 00:00:00 – Introduction
  • 00:01:55 – The Recursive Book of Recursion
  • 00:02:55 – A Beginner’s Guide to Recursion - YouTube
  • 00:05:41 – What is recursion?
  • 00:10:17 – Understanding the call stack
  • 00:12:15 – Languages moving from GOTO statements to functions and a stack
  • 00:21:11 – A common recursion example of factorials
  • 00:26:00 – Fibonacci sequence and memoization
  • 00:30:25 – Cautionary advice on applying recursion
  • 00:32:55 – What is recursion useful for?
  • 00:39:56 – Video Course Spotlight
  • 00:41:14 – Recursion and directed acyclic graphs
  • 00:45:46 – Book examples
  • 00:49:50 – Thoughts on tail recursion
  • 00:54:34 – How has the scope of the book evolved?
  • 01:00:34 – Creating examples in two languages
  • 01:02:37 – Upcoming projects
  • 01:05:19 – Examples of the projects in the book
  • 01:10:30 – What are you excited about in the world of Python?
  • 01:14:50 – What do you want to learn next?
  • 01:19:06 – How can people follow your work?
  • 01:19:48 – Thanks and goodbye

Show Links: