Python Docstrings

  1. Summary Line
  2. Additional Paragraphs
  3. Optional Sections

Sections

File:

  • Author
  • Version

Class:

  • Attributes

Method:

  • Args
  • Returns
  • Raises

File Comment

"""Implements a Square shape.
This file contains code for the Square shape class.
Author: Russell Feldhausen russfeld@ksu.edu Version: 0.1 """

Class Comment

class Square:
    """Represents a Square shape.
This class represents a square, storing the side length only.
Attributes: length: the side length of the square """

Method Comment

def area_difference(circle: Circle) -> float:
    """Calculates the area of the square not in the circle.
This method will place the center of the circle at the center of the square and compute the difference in area.
Args: circle: a circle shape
Returns: the difference in area as a float
Raises: ValueError: if the circle is larger than the square """