Skip to content

Python / Training Session / Writing Good Code

The resources in the following table describe how to write good Python code.

Training Session Summary

Lesson/Task Description
Prerequisites As needed...
Session - Python Setup Setting up Python for development.
Lesson Sequence
See below: Introduction Introduction.
Lesson - Python Style Guide Python style guide.
Lesson - Type Hints Type hints to help with typing.
Lesson - Code Documentation Code documentation.
Lesson - Exception Handling Exception handling.

Introduction

This session provides guidance for writing "good Python code". Many of these topics are common to all programming languages. The definition of "good code" is subject to some interpretation, and this documentation attempts to provide general guidance as well as presenting contrasting opinions where appropriate. It is generally better to follow common sense and recognized standards where possible than to argue without compromise about programming.

Python has its own "pythonic" way of programming that in some cases is similar to other languages and in other cases is quite different. Standard Python guidelines such as the PEP 8 - Style Guide for Python Code should be followed where possible.

Other lessons learned from multiple programming languages provide guidance for good code.