Skip to content

Commit 2b11ea9

Browse files
committed
Closure
1 parent abdb6bc commit 2b11ea9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,10 @@ creature = Creature()
536536

537537
Closure
538538
-------
539+
**We have a closure in Python when:**
540+
* **A nested function references a value of its enclosing function, and then**
541+
* **the enclosing function returns the nested function.
542+
539543
```python
540544
def get_multiplier(a):
541545
def out(b):
@@ -549,6 +553,8 @@ def get_multiplier(a):
549553
30
550554
```
551555

556+
* **If multiple nested functions within enclosing function reference the same value, that value gets shared.**
557+
552558
#### Or:
553559
```python
554560
from functools import partial

0 commit comments

Comments
 (0)