CSC 231 Python code expectations and conventions

Documentation

  1. All code that you submit must be documented, both at the class level and the method/function level, using Python docstring comments as illustrated in this example. All code means all code - including any code you write and any code given to you as a part of the assignment. If you are submitting it, it must be documented. Here is the official Python guidance on docstrings.

Coding style

Adapted from the Python PEP-8 style guide. Here is the section on naming conventions.

  1. Python file names must use all lowercase, with words separated by underscores as necessary to improve readability. For example, bank_account.py
  2. Class names must use camel case, for example BankAccount
  3. Typically, each class will be placed in its own file. For example, the class BankAccount will be declared in the file bank_account.py and this file will contain nothing else.
  4. Function names, method names, and variables names must use all lowercase names, with words separated by underscores as necessary to improve readability.
  5. Choose descriptive names for variables.  
  6. Declare variables with the proper scope. For example, don't create an instance variable when a local variable will do.
  7. Use blank lines and whitespace to improve readability of your code. Code that appears crammed is hard to read.