Python Inner Functions

Python allows the declaration of functions inside of other functions. Inner functions, also known as nested functions, are defined within a function. This type of function has direct access to variables and names defined in the enclosing function in Python. Inner functions have many uses, most notably as closure factories and decorator functions.

In this course, you’ll learn how to:

  • Define inner functions
  • Use inner functions as helper functions
  • Build function closures
  • Use captured variables in a closure
  • Use captured data functions in a closure
  • Work with decorators

What’s Included:

Downloadable Resources:

Related Learning Paths:

About Christopher Trudeau

Christopher Trudeau Christopher Trudeau

Christopher has a passion for the Python language and writes for Real Python. He is a consultant who helps advise organizations on how to improve their technical teams.

» More about Christopher

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

Participant Comments

jkueng on July 7, 2021

Very well done and insightful. The background of how inner functions are tied to functional programming really gave me context on why they are important.

Jesus Espinoza on July 5, 2021

Great course!!! Really helpful!!!

« Browse All Courses