File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -599,9 +599,11 @@ def get_counter():
599
599
600
600
Decorator
601
601
---------
602
+ ** A decorator takes a function, adds some functionality and returns it.**
603
+
602
604
``` python
603
- @closure_name
604
- def function_that_gets_passed_to_closure ():
605
+ @decorator_name
606
+ def function_that_gets_passed_to_decorator ():
605
607
...
606
608
```
607
609
@@ -638,17 +640,17 @@ def fib(n):
638
640
CacheInfo(hits = 28 , misses = 16 , maxsize = None , currsize = 16 )
639
641
```
640
642
641
- ### Parametrized Decorator
643
+ ### Parametrized Example
642
644
``` python
643
645
def debug (print_result = False ):
644
- def inner_decorator (func ):
646
+ def decorator (func ):
645
647
@wraps (func)
646
648
def out (* args , ** kwargs ):
647
649
result = func(* args, ** kwargs)
648
650
print (func.__name__ , result if print_result else ' ' )
649
651
return result
650
652
return out
651
- return inner_decorator
653
+ return decorator
652
654
653
655
@debug (print_result = True )
654
656
def add (x , y ):
You can’t perform that action at this time.
0 commit comments