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. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130415/67f2843e/attachment.html>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4