·[强制] [PY033] 使用 docstring 描述 module、function、class 和 method 接口。docstring 必须用三个双引号括起来。
·[强制] 对外接口部分必须用 docstring 描述,内部接口视情况自行决定是否写 docstring。
·[强制][PY034] 接口的 docstring 描述至少包括功能简介、参数、返回值。如果可能抛出异常,必须注明。
·[强制] 每个文件都必须有文件声明,文件声明必须包括以下信息:版权声明,功能和用途简介,修改人及联系方式。
·[建议] TODO 注释格式必须为:
- #TODO: 干什么事情$负责人 (邮箱前缀) $最终期限 (YYYY - MM - DD) $
定义
解释
示例
- ##################################################################################Copyright(c) 2014 Baidu.com,
- Inc.All Rights Reserved#################################################################################"""
- This module provide configure file management service in i18n environment.
-
- Authors: jiangjinpeng([email protected])
- Date: 2014/04/05 17:23:06
- """
- def fetch_bigtable_rows(big_table, keys, other_silly_variable = None) : """Fetches rows from a Bigtable.
-
- Retrieves rows pertaining to the given keys from the Table instance
- represented by big_table. Silly things may happen if
- other_silly_variable is not None.
-
- Args:
- big_table: An open Bigtable Table instance.
- keys: A sequence of strings representing the key of each table row
- to fetch.
- other_silly_variable: Another optional variable, that has a much
- longer name than the other args, and which does nothing.
-
- Returns:
- A dict mapping keys to the corresponding table row data
- fetched. Each row is represented as a tuple of strings. For
- example:
-
- {'Serak': ('Rigel VII', 'Preparer'),
- 'Zim': ('Irk', 'Invader'),
- 'Lrrr': ('Omicron Persei 8', 'Emperor')}
-
- If a key from the keys argument is missing from the dictionary,
- then that row was not found in the table.
-
- Raises:
- IOError: An error occurred accessing the bigtable.Table object.
- """pass
- class SampleClass(object) : """Summary of class here.
-
- Longer class information....
- Longer class information....
-
- Attributes:
- likes_spam: A boolean indicating if we like SPAM or not.
- eggs: An integer count of the eggs we have laid.
- """
-
- def __init__(self, likes_spam = False) : """Inits SampleClass with blah."""self.likes_spam = likes_spam self.eggs = 0
-
- def public_method(self) : """Performs operation blah."""
- #TODO: Improve performance using concurrent operation.$jiangjinpeng$2014 - 04 - 05$
来源: http://www.bubuko.com/infodetail-2231018.html