OEP: 2 Title: Python Style Guide Author: Brian Bingham Status: Active Type: Process Content-Type: text/x-rst Created: 14-Apr-2016 Post-History: 14-Apr-2016

2   Python Style Guide

2.1   External Python Style Guides

For OER projects it is recommended that developers follow Google’s Python Style Guide: https://google.github.io/styleguide/pyguide.html which appears to be consistent with PEP8 https://www.python.org/dev/peps/pep-0008/

2.2   Reusable Code

Andy wants to, “iterate toward the best method to support using the script as a program, importing it into another script, executing while developing and executing when installed. Some of this is design and some is packaging.”

2.3   Common Modules

  • Use argparse for command line arguments.
  • Use pytest for unit tests.
  • Use the logging module verbosity control. We want to “be able to redirect log to file, modify log level of only selected functions/classes without modifying the code, make sure our library code behaves properly and some others” To support this it would be nice to point to a working/ideal example.