Question: What is Python Closures?Answer:As we have already discussed, closure is a nested function that helps us access the outer function's variables even after the outer function is closed. For example,
Output:
In the above example, we have created a function named greet() that returns a nested anonymous function. |
Is it helpful?
Yes
No
Most helpful rated by users:
- What is Python?
- How do I share global variables across modules?
- How do you set a global variable in a function in Python?
- What type of language is Python? Programming or Scripting?
- Why can\'t I use an assignment in an expression?