Are docstrings for internal functions (python) necessary? [closed]

烈酒焚心 提交于 2021-02-06 14:47:07

问题


In python we designate internal function/ private methonds with an underscore at the beginning. Should these functions be documented with docstrings(is it required?)? (the formal documentation i mean, not the one helping the code-reader to understand the code) What is common practice for this?


回答1:


Lo, I quote from PEP 8, the wise words of which should be considered law. Upon this very topic, PEP 8 saith:

  • Write docstrings for all public modules, functions, classes, and methods. Docstrings are not necessary for non-public methods, but you should have a comment that describes what the method does. This comment should appear after the "def" line.


来源:https://stackoverflow.com/questions/7687407/are-docstrings-for-internal-functions-python-necessary

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!