Workflows with Python and Git

Key Points

Review Exercise
  • Use skills together.

Command-Line Programs
  • The sys library connects a Python program to the system it is running on.

  • The variable sys.argv is a list with each item being a command-line argument.

Trying Different Methods
  • Make different branches in a Git repository to try different methods.

  • Use bash’s time command to time scripts.

Program Flags
  • Adding command line flags can be a user-friendly way to accomplish common tasks.

Defensive Programming
  • Avoid silent failures.

  • Avoid esoteric output when a program fails.

  • Add checkpoints in code to check for common failures.

  • Refactoring makes code more modular, easier to read, and easier to understand.

  • Refactoring requires one to consdier future implications and generally enables others to use your code more easily.

Running Scripts and Importing
  • The __name__ variable allows us to know whether the file is being imported or run as a script.

Programming Style
  • Follow standard Python style in your code.

  • Use docstrings to provide online help.

  • Python supports a large community within and outwith research.

FIXME: more reference material.


FIXME: glossary.