Skip to content

Update lesson 18-style to follow google style guide for function docstrings #359

@mikewolfe

Description

@mikewolfe

In the Programming Style lesson the google style guide for writing function docstrings is mentioned, but the style of the example docstrings in the lesson do not follow the google style guide. It may be worth introducing users to the idea of a google style function docstring like the example in the google style guide:

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

This would force new users to think about what a function does, what inputs it takes in, and what output it returns, thereby encouraging good style practices and reinforcing the learning goals for functions at the same time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood issue for first-time contributorshelp wantedLooking for Contributorstype:discussionDiscussion or feedback about the lesson

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions