This week, we wil talk about several strategies for writing “good” code: code that is clear, modular, flexible, and easy to troubleshoot.
Some of the things you will learn this week:
The basics of Python’s module and package system, and how to import modules into your script or session.
Why you should write your own functions, and learn how to write them in Python.
How to properly structure your code.
How to run Python scripts from the shell.
How to interpret and handle errors.
Better understand the difference between mutable and immutable Python data structures and the need to explicitly copy mutable data structures.
And optionally:
Python coding style guidelines for clear code.
How to debug Python code with a debugger.
What unit testing and profiling is, and how to perform some basic implementations of this in Python.
CSB Chapter 4: “Writing Good Code”
Section 4.6-4.8 on debugging, unit testing, and profiling, respectively, are optional.
But don’t forget the last section, 4.9 (“Beyond the Basics”)!
Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".