|
@@ -5,6 +5,22 @@ Just notes on various things
|
|
|
## docstrings
|
|
|
Use 'em.
|
|
|
|
|
|
+### doctest
|
|
|
+In your docstring, put examples that look like the command-line, such as
|
|
|
+```
|
|
|
+def square(x):
|
|
|
+ """
|
|
|
+ Returns x times itself.
|
|
|
+ >>> square(2)
|
|
|
+ 4
|
|
|
+ """
|
|
|
+ return x*x
|
|
|
+```
|
|
|
+Then `import doctest` and `doctest.testmod()` inside `__main__`, and python will run the
|
|
|
+tests to verify correctness.
|
|
|
+
|
|
|
+Run with `python -v` to see the output of the doctest module.
|
|
|
+
|
|
|
## ArgParse
|
|
|
|
|
|
|