Created
December 27, 2020 08:01
-
-
Save rezkam/d43e279ae059c496cda5acab76d00535 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import wraps | |
def simple_decorator(func): | |
def __wrapper(*args, **kwargs): | |
return func(*args, **kwargs) | |
return __wrapper | |
def with_wraps(func): | |
@wraps(func) | |
def __wrapper(*args, **kwargs): | |
return func(*args, **kwargs) | |
return __wrapper | |
@simple_decorator | |
def simple(): | |
"""Here is simple doc string text.""" | |
pass | |
@with_wraps | |
def wrapper(): | |
"""Here is wrapper doc string text.""" | |
pass | |
# without using @wraps decorator | |
print(simple.__doc__) | |
#>>> None | |
print(simple.__name__) | |
#>>> __wrapper | |
# using @wraps decorator | |
print(wrapper.__doc__) | |
#>>> Here is wrapper doc string text. | |
print(wrapper.__name__) | |
#>>> wrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment