Created
May 5, 2024 12:17
-
-
Save sunfkny/0cbb65dcb4bd063fae30870f837bd89f to your computer and use it in GitHub Desktop.
This file contains 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
def docstring_decorator(s): | |
""" | |
动态修改docstring装饰器 | |
>>> a = "test" | |
>>> @docstring_decorator(f"a={a}") | |
>>> def f(): | |
>>> pass | |
>>> print(f.__doc__) # a=test | |
""" | |
def _decorator(obj): | |
obj.__doc__ = str(s) | |
return obj | |
return _decorator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment