MemotivaFunctions and arguments

What is a closure in Python?

Functions and arguments

Audio flashcard · 0:16

Nortren·

What is a closure in Python?

0:16

A closure is a function defined inside another function that captures variables from the enclosing scope. The inner function retains access to those variables even after the outer function has returned. Closures are commonly used to create functions with preconfigured behavior, such as decorators and factory functions.
docs.python.org