Setting the file. One moment.
Subchapter 27.2
references/python.mdMarkdown3 KBView on GitHub
""" ... """ for documentation that describes usage, arguments, and return values (public API) to make them accessible via __doc__ and tools like pydoc.# for implementation details relevant only to developers reading the source.Follow the Google Python Style Guide (opens in a new tab) for docstrings.
""".def fetch_bigtable_rows(table_handle, other_silly_variable=None):
"""Fetches rows from a Bigtable.
Retrieves rows pertaining to the given keys from the Table instance
represented by table_handle. String keys will be UTF-8 encoded.
Args:
table_handle: An open smalltable.Table instance.
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 row is not found, it is not included in the dict.
Raises:
IOError: An error occurred accessing the bigtable.Table object.
"""
passYields for generators). You may omit this section if the function returns None, though explicit documentation is preferred.Inline Types: Omit type information from the docstring arguments if you use PEP 484 type hints (strongly recommended) to avoid duplication and drift.
def greet(name: str) -> str:
"""Returns a greeting.
Args:
name: The person to greet.
Returns:
The greeting string.
"""
return f"Hello, {name}"Provide a top-level docstring in every file describing its contents and usage.
"""A one-line summary of the module or program, terminating in a period.
Leave one blank line. The rest of this docstring should contain an
overall description of the module or program. Optionally, it may also
contain a brief description of exported classes and functions and/or usage
examples.
Typical usage example:
foo = ClassFoo()
bar = foo.FunctionBar()
"""Describe the class and its usage. Document public attributes here under an Attributes section.
class SampleClass:
"""Summary of class here.
Longer class information....
Attributes:
likes_spam: A boolean indicating if we like SPAM.
eggs: An integer count of the eggs we have.
"""
def __init__(self, likes_spam: bool = False):
"""Inits SampleClass with default values."""
self.likes_spam = likes_spam
self.eggs = 0