Link Search Menu Expand Document

Python

Table of contents
  1. Casing reminder
  2. Indentation
  3. Strings

The SDX Python coding standards should follow PEP 8. This is usually automatically checked when using Jetbrains IDE’s such as Pycharm.

Casing reminder

Name Casing
Function names snake_case
Function parameters snake_case
Variables snake_case
Classes PascalCase
Class methods snake_case
Global constants UPPER_SNAKE_CASE

Indentation

4 spaces per indention level should be used and spaces should be preferred over tabs, this can easily be configured in most IDE’s by using “Smart Tabs”

Strings

Unless required all strings should double quotes, a common exception to this might be if a double quoted sentence is needed inside a string (see code below)

# Standard string
name = "Nigel"
# Embedded strings
my_sentence = 'Jon calmly asked Luke "Why did you delete the prod environment?"'

© 2022 ONS-SDX