Skip to content

Commit bd4bcdc

Browse files
committed
Decorator
1 parent 922f6c0 commit bd4bcdc

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -599,9 +599,11 @@ def get_counter():
599599

600600
Decorator
601601
---------
602+
**A decorator takes a function, adds some functionality and returns it.**
603+
602604
```python
603-
@closure_name
604-
def function_that_gets_passed_to_closure():
605+
@decorator_name
606+
def function_that_gets_passed_to_decorator():
605607
...
606608
```
607609

@@ -638,17 +640,17 @@ def fib(n):
638640
CacheInfo(hits=28, misses=16, maxsize=None, currsize=16)
639641
```
640642

641-
### Parametrized Decorator
643+
### Parametrized Example
642644
```python
643645
def debug(print_result=False):
644-
def inner_decorator(func):
646+
def decorator(func):
645647
@wraps(func)
646648
def out(*args, **kwargs):
647649
result = func(*args, **kwargs)
648650
print(func.__name__, result if print_result else '')
649651
return result
650652
return out
651-
return inner_decorator
653+
return decorator
652654

653655
@debug(print_result=True)
654656
def add(x, y):

0 commit comments

Comments
 (0)