Skip to content

Instantly share code, notes, and snippets.

@dmyersturnbull
Created May 5, 2020 01:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmyersturnbull/bb0e3b469326fe0810271e62ef5bffff to your computer and use it in GitHub Desktop.
Save dmyersturnbull/bb0e3b469326fe0810271e62ef5bffff to your computer and use it in GitHub Desktop.
Python copy-docstring decorator.
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