Code standards

Naming rules

These apply to variables, functions, and parameters.

  • Make all names lowercase.
  • Don't use Python keywords for your own names.
  • Use underscores (_) to separate parts of names.
  • Use meaningful names.

Examples:

  • goat_count
  • doggo_awesomeness
  • spider_awesuckness

When I name a boolean var, I try to use is (or was or similar) at the beginning, like:

  • is_taxable
  • is_data_valid

Function comments

Docstring sample:

  •     '''
  •     Input a cat count. Loop until user enters a valid integer.
  •  
  •     Parameters
  •     ----------
  •     prompt : string
  •         Question for the user.
  •     max : int
  •         Maximum number of cats.
  •  
  •     Returns
  •     -------
  •     cats : int
  •         Number of cats.
  •  
  •     '''

Spyder can make a template for you.

Type the function def, including the :. Press Enter. Type ''' (three quotes). Spyder will offer to make a docstring for you.