Python 为什么不用 doxygen 这种清晰明了的注释风格?

2017-09-19 22:45:57 +08:00
 SimbaPeng
python 的注释:
def round(number, ndigits=None): # real signature unknown; restored from __doc__
"""
round(number[, ndigits]) -> number

Round a number to a given precision in decimal digits (default 0 digits).
This returns an int when called with one argument, otherwise the
same type as the number. ndigits may be negative.
"""
return 0

doxygen:
/**
* Checks if value is a member of the set stored at the key key.
*
* @param string $key
* @param string $value
* @return bool TRUE if value is a member of the set at key key, FALSE otherwise.
* @link http://redis.io/commands/sismember
* @example
* <pre>
* $redis->sAdd('key1' , 'set1');
* $redis->sAdd('key1' , 'set2');
* $redis->sAdd('key1' , 'set3'); // 'key1' => {'set1', 'set2', 'set3'}
*
* $redis->sIsMember('key1', 'set1'); // TRUE
* $redis->sIsMember('key1', 'setX'); // FALSE
* </pre>
*/

我感觉 doxygen 的注释风格非常清晰明了,一眼就看出参数类型,返回值类型。而 python 的注释却是使用大量文字来解释,而且没有一个规定的排版。这是为什么?
5701 次点击
所在节点    Python
24 条回复
NathanHu
2017-09-20 18:42:22 +08:00
不同语言有不同注释,习惯就好,就算你知道了为什么也无法改变它,只能适应它。
srlp
2017-09-22 19:54:34 +08:00
楼主这是引战啊,明显是历史原因嘛。

另外,你想要的格式也是有的,numpy doc format:
srlp
2017-09-22 19:54:41 +08:00
srlp
2017-09-22 19:59:15 +08:00

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/392092

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX