Recently I helped out on issue16954 which involved filling in docstrings
for methods and classes in ElementTree.py
While doing so, I tried to test my work in the interpreter like this...
>>> from xml.etree.ElementTree import Element
>>> help(Element)
...but found that help() showed nothing but empty strings!
After some debugging, I found that the culprit was the
`from _elementtree import *` near the bottom of the module.
Not wanting to copy & paste docstrings around, I thought one solution
might be to just reassign Element.__doc__ with the right docstring.
But, it seems that you can't do that for C extensions:
>>> from _elementtree import Element as cElement
>>> cElement.__doc__ = 'correct docstring'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't set attributes of built-in/extension type 'xml.etree.ElementTree.Element'
---
Q. Is there way to maintain the same docstring without
resorting to copying and pasting it in two places?
I tried to find an example in the source which addressed this, but
found that the docstrings in similar cases to be largely duplicated.
For instance, _datetimemodule.c, decimal_.c and _json.c all seem to
exhibit this docstring copy and pastage.