1. python 文档字符串

来源:互联网 发布:js 过滤特殊字符 编辑:程序博客网 时间:2024/05/25 19:56

Document String:

Here are some conventions about the content and formatting of documentation string:

The first line should be short, concise summary of the obejct's purpose. For brevity, it should not explicitly state the object's name or type,since these are available by other means . This line begin with a capital letter and end with a period.

If there are more lines in the documentations string.the second lines should be a blank. visually separating the summary from the rest of the description.The following lines should be one or more paragraphs describing the object's calling conventions ,its side effect,etc.

The Python parser does not strip indentation from the multi-line string liberals in Python. So tools that process documentation have to strip indentation if desired.This is done using the following convention. The first non-blank line after the first line of the string determines that the amount of indentation for the entire document string.whitespace "equivalent" to this indentation is then stripped from the start of all lines of the string .Lines that are indented less should not occur, but if they occur all their leading whitespace should be stripped. Equivalence of whitespace  should be tested after expansion of tabs.

Here are example of the multi-line docstring:

<pre name="code" class="python" style="text-align: justify;">def my_function():    """ hey , first line is a short ,concise summary                  ok, the second line is a blank line ,it separating the summary from the rest of the description.
<span style="white-space:pre"></span>"""
print (my_function.__doc__)



0 0
原创粉丝点击