Browse Source

Closure

pull/3/head
Jure Šorn 5 years ago
parent
commit
aabd2c1625
1 changed files with 2 additions and 3 deletions
  1. 5
      README.md

5
README.md

@ -489,19 +489,18 @@ creature = Creature()
Closure
-------
```python
def multiply_closure(a):
def get_multiplier(a):
def out(b):
return a * b
return out
```
```python
>>> multiply_by_3 = multiply_closure(3)
>>> multiply_by_3 = get_multiplier(3)
>>> multiply_by_3(10)
30
```
#### Or:
```python
from functools import partial

Loading…
Cancel
Save