美文网首页
python注释 -- 函数注释和类注释

python注释 -- 函数注释和类注释

作者: fada492daf5b | 来源:发表于2018-01-28 14:15 被阅读0次

1. 作用

方便维护和阅读

2. 操作

函数注释

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."""

相关文章

  • python注释 -- 函数注释和类注释

    1. 作用 方便维护和阅读 2. 操作 函数注释 类注释

  • PhpStorm下文件/方法注释格式自定义

    [PhpStorm 头部注释、类注释和函数注释的设置(稍微完善点)] 首先,PhpStorm中文件、类、函数等注释...

  • Python3 注释

    确保对模块, 函数, 方法和行内注释使用正确的风格 Python中的注释有单行注释和多行注释: Python中单行...

  • python3-注释

    Python3 注 确保对模块, 函数, 方法和行内注释使用正确的风格 Python中的注释有单行注释和多行注释:...

  • python3 注释

    确保对模块、函数、方法和行内注释使用正确的风格。python 中的注释有单行注释和多行注释。 单行注释 Pytho...

  • Lesson 011 —— python 注释

    Lesson 011 —— python 注释 确保对模块, 函数, 方法和行内注释使用正确的风格 Python中...

  • 一起学Python系列|Python基础语法

    Python基础语法 一、注释 Python中的注释有单行注释和多行注释: 1.1 单行注释 Python中单行注...

  • Python3 注释

    Python中的注释有单行注释和多行注释 Python中单行注释以 # 开头,例如: 多行注释用三个单引号 '''...

  • python基本知识

    python注释单行注释 #这是注释内容多行注释 ''' 这是注释内容 ''' python一些保留字and,...

  • Python单行注释和多行注释分别用什么?

    作者:Gakki Python单行注释和多行注释分别用什么? 单行注释用# 多行注释用""" """

网友评论

      本文标题:python注释 -- 函数注释和类注释

      本文链接:https://www.haomeiwen.com/subject/mxaaaxtx.html