Skip to main content

Python Best Practice

Introduction

This document is a guide to writing Python code in the Operations Engineering team. It is a living document, and will be updated as we develop a greater understanding of the language and how we intend to use it.

General

Use autopep8 for code formatting

We should be using autopep8 to format our code. This will ensure that all of our code is formatted in the same way, and will make it easier to read.

To install autopep8:

python -m pip install autopep8

To format a file:

autopep8 --in-place <filename>

Use pylint for code linting

We should be using pylint to lint our code. This will ensure that our code is written in a consistent way, and will make it easier to read.

To install pylint:

python -m pip install pylint

To lint a file:

pylint <filename>
This page was last reviewed on 5 September 2024. It needs to be reviewed again on 5 December 2024 by the page owner #operations-engineering-alerts .