Created
May 5, 2020 01:26
-
-
Save dmyersturnbull/bb0e3b469326fe0810271e62ef5bffff to your computer and use it in GitHub Desktop.
Python copy-docstring decorator.
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
from typing import Type | |
from functools import wraps | |
def copy_docstring(from_obj: Type): | |
""" | |
Decorator. | |
Copies the docstring from `from_obj` to this function or class. | |
""" | |
@wraps(copy_docstring) | |
def dec(myobj): | |
myobj.__doc__ = from_obj.__doc__ | |
return myobj | |
return dec |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment