Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
Python Style Guide

This page contains guidelines for Python source code for the Paparazzi project.

PEP8 is the de-facto code style guide for Python and covers the most important aspects.

There exists a command-line program, pep8, that can check your code for conformance.

Formatting Guide

  • Use 4 spaces per indentation level, do NOT use tabs.
  • Remove any trailing white space at the end of lines.
  • Use Unix line endings ('\n'); do NOT use DOS endings ('\r\n')

Python 2 and 3 compatibility

Try to write python code so that it works with python2 (>=2.6) and python3. See e.g. supporting Python 2 and 3 without 2to3 conversion for details.

The most common things to keep in mind:

Basic example:

from __future__ import print_function
from __future__ import division
def halve_example(x, y=2):
"""Example function to show division."""
return x / y
if foo == "bar":
try:
print("Ups...", detail)