擅长:python、mysql、java
<p><a href="https://github.com/google/styleguide" rel="noreferrer">Google style guide</a>包含一个优秀的Python风格指南。它包括<a href="https://google.github.io/styleguide/pyguide.html#Comments" rel="noreferrer">conventions for readable docstring syntax</a>比PEP-257提供更好的指导。例如:</p>
<pre><code>def square_root(n):
"""Calculate the square root of a number.
Args:
n: the number to get the square root of.
Returns:
the square root of n.
Raises:
TypeError: if n is not a number.
ValueError: if n is negative.
"""
pass
</code></pre>
<p>我喜欢将其扩展到参数中也包括类型信息,如<a href="https://pythonhosted.org/an_example_pypi_project/sphinx.html#full-code-example" rel="noreferrer">Sphinx documentation tutorial</a>中所述。例如:</p>
<pre><code>def add_value(self, value):
"""Add a new value.
Args:
value (str): the value to add.
"""
pass
</code></pre>