Browse Source

Random

pull/3/head
Jure Šorn 6 years ago
parent
commit
8496d65d75
1 changed files with 10 additions and 5 deletions
  1. 15
      README.md

15
README.md

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

Loading…
Cancel
Save