We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 9 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
将 Python 文档字符串包含在“代码行”计数中可能是正确的。通常,编译器会丢弃注释,但会解析文档字符串:
请参阅 PEP 257 - 文档字符串约定:
换句话说,文档字符串以非常真实的方式编译并构成程序的代码。此外,它们通常被
doctest 模块
用于单元测试,如用法命令行实用程序的字符串等。It is probably correct to include Python docstrings in a "lines of code" count. Normally a comment would be discarded by the compiler, but docstrings are parsed:
See PEP 257 - Docstring Conventions:
In other words, docstrings are compiled and constitute, in a very real way, the code of the program. Additionally, they're commonly used by the
doctest module
for unit testing, as usage strings for command line utilities, and so on.注释行可以是 python 中的代码行。例如,请参阅
doctest
。此外,您将很难找到一种明智/可靠的方法来将这样的情况视为注释或代码:
也只需计算注释行,我认为大多数程序员都会同意这对于您来说是一个很好的衡量标准实际上正在尝试测量。
Comment lines can be lines of code in python. See
doctest
for example.Moreover, you will have trouble to find a sensible/reliable way to consider a case like this as being a comment or code:
Just count the comment lines as well, I think most programmers will agree it is as good a measure for whatever you are actually trying to measure.
Tahar 不计算文档字符串。这是它的 count_loc 函数:
Tahar doesn't count the docstrings. Here's its count_loc function :
你有没有看过http://www.ohloh.net/p/ohcount - 总是很漂亮对我来说钱 - 虽然我不使用 python
Have you looked at http://www.ohloh.net/p/ohcount - always been pretty on the money for me - although I do not use python