Coding Style

Python

String Literals

Prefer single quotes to double quotes unless the string itself contains single quotes that would need to be needlessly escaped.

Wrapping Code

When wrapping code follow the "hanging grid" format:

some_dict = {
'one': 1,
'two': 2,
'three': 3}

some_list = [
'foo', 'bar', 'baz']

Python is an indent-based language and we believe that beautiful, readable code is more important than saving a single line of git diff. Please avoid dangling parentheses, brackets, square brackets or hanging commas even if the Django project seems to encourage this programming style:

this_is_wrong = {
'one': 1,
'two': 2,
'three': 3,
}

Please break multi-line code immediately after the parenthesis and avoid relying on a precise number of spaces for alignment:

also_wrong('this is hard',
'to maintain',
'as it often needs to be realigned')