CSC 231 Python code expectations and conventions
Documentation
- 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.
- Python file names must use all lowercase, with words separated by underscores as necessary to improve readability. For example, bank_account.py
- Class names must use camel case, for example BankAccount
- 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.
- Function names, method names, and variables names
must use all lowercase names, with words separated by underscores as
necessary to improve readability.
- Choose descriptive names for variables.
- Declare variables with the proper scope. For example, don't create an instance variable when a local variable will do.
- Use blank lines and whitespace to improve readability of your code. Code that appears crammed is hard to read.