diff --git a/README.md b/README.md index 2d7137e..b6e88cc 100644 --- a/README.md +++ b/README.md @@ -536,6 +536,10 @@ creature = Creature() Closure ------- +**We have a closure in Python when:** +* **A nested function references a value of its enclosing function, and then** +* **the enclosing function returns the nested function. + ```python def get_multiplier(a): def out(b): @@ -549,6 +553,8 @@ def get_multiplier(a): 30 ``` +* **If multiple nested functions within enclosing function reference the same value, that value gets shared.** + #### Or: ```python from functools import partial