Grokking Advanced Python
0% completed
Python - Closures
Closures in Python are a key concept that falls under the category of first-class functions. A closure is a function object that remembers values in enclosing scopes even after the enclosing function has finished running. They are typically used for function factories, which can create configurations for other functions, or to hide state in generated functions.
Understanding Closures
A closure allows a function to access variables from an outer function that has finished its execution. This occurs when:
- A nested function references a value in its enclosing function. 2
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%