|
@ -490,9 +490,9 @@ Closure |
|
|
------- |
|
|
------- |
|
|
```python |
|
|
```python |
|
|
def multiply_closure(a): |
|
|
def multiply_closure(a): |
|
|
def wrapped(b): |
|
|
|
|
|
|
|
|
def out(b): |
|
|
return a * b |
|
|
return a * b |
|
|
return wrapped |
|
|
|
|
|
|
|
|
return out |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
```python |
|
|
```python |
|
@ -508,6 +508,12 @@ from functools import partial |
|
|
partial(<function>, <arg_1> [, <arg_2>, ...]) |
|
|
partial(<function>, <arg_1> [, <arg_2>, ...]) |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
```python |
|
|
|
|
|
>>> multiply_by_3 = partial(lambda a, b: a*b, 3) |
|
|
|
|
|
>>> multiply_by_3(10) |
|
|
|
|
|
30 |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Decorator |
|
|
Decorator |
|
|
--------- |
|
|
--------- |
|
|