内部函数(python)的文档字符串是否必要? [英] Are docstrings for internal functions (python) necessary?
本文介绍了内部函数(python)的文档字符串是否必要?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在python中,我们在内部函数/私有方法的开头加了下划线.这些功能是否应该使用docstrings记录下来(是否需要?)?(我的意思是正式文档,而不是帮助代码阅读器理解代码的文档).这是常见的做法?
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?
推荐答案
Lo,我引用了 PEP 8 ,其明智之词应视为法律.关于这个话题,PEP 8说:
Lo, I quote from PEP 8, the wise words of which should be considered law. Upon this very topic, PEP 8 saith:
- 为所有公共模块,函数,类和方法.对于非公共方法,文档字符串不是必需的,但是您可以应该有描述该方法功能的注释.此评论应该出现在"def"行之后.
这篇关于内部函数(python)的文档字符串是否必要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文