You can test most of the items in the "Formatting" section by copying your program to the cwolf server, logging into cwolf and navigating to the correct directory, and running the following command. Fill in the name of your file where indicated:
~srivoire/bin/python_style_check.sh yourprogram
Pay attention to any output this program prints. If it doesn't produce any output, then you're in good shape.
The error codes refer to the Python PEP 8 style guide, which is the basis of these rules.
Here is how to read an error message from this command:
proj1.py:10:1: W293 blank line contains whitespace ^
The "10:1" means that the error occurred on line 10, column 1 of your source code file. You can reopen emacs directly to this line by using a "+10" (since you want line 10):
emacs +10 proj1.py
The "W293" refers to the PEP8 rule that your code violates. In this example, a "blank" line in the source code actually has invisible tabs or spaces.
Finally, the error message will show the offending line of your code, and put a
^symbol underneath the specific error. Since this source code had extra space in a "blank" line, it printed a blank line and marked the beginning of that line.
[2] | There is a docstring at the top of the submitted file with your name (first and last), the course (CS 115) and assignment (Project 2), and a brief description of the program. |
-1 | Missing one piece of required information |
-1 | Missing two or more pieces of required information |
[5] | Program is broken up into logical, well-defined functions. Functions perform specific, well-defined jobs and have descriptive names. Functions are no more than 20 lines of code. |
-1 | Minor lapses |
-3 | Major flaws |
-5 | Program does not have student-written functions |
[2] | Functions have no more parameters than necessary to do their jobs. Return values are used appropriately. |
-1 | Minor flaws |
-2 | Program does not have student-written functions |
[4] | Each function includes a docstring explaining the job it does, its input parameters, its return value, and any assumptions it makes about its inputs. |
-1 | Minor lapses |
-2 | Some functions do not have comments, or comments do not contain the required info |
-4 | Most functions do not have comments |
Not counting the docstrings for your program and functions, your program should contain at least three comments explaining aspects of your code that are potentially tricky for a person reading it to understand. You should assume that the person understands what Python syntax means but may not understand why you are doing what you are doing.
[3] | You have at least 3 useful comments (1 point each) |
[4] | All variables and functions have descriptive names that indicate what they are used for |
[1] | Indentation:
|
[2] | Line length and spacing:
|
[3] | Spacing within statements:
|
[2] | Your algorithm is straightforward and easy to follow. |
[2] | Your algorithm is reasonably efficient, with no wasted computation or unused variables. |
You will lose 5 points for having ANY statements outside of a function definition. There are only three exceptions to this rule:
You will also lose 5 points for using the global keyword, which subverts the point of functions.
For students using language features that were not covered in class, up to 5 points may be taken off if the principles of programming style are not adhered to when using these features. If you have any questions about what this means, ASK!