C indentation style (was RE: [Python-Dev] Re: [Patches] [Patch #102813] _cursesmodule: Add panel support)

Guido van Rossum guido@digicool.com
Wed, 27 Dec 2000 16:04:27 -0500

> 2. Guido repeats that he prefers old-style (but in a wishy-washy way that
> leaves it uncertain (*)).

OK, since a pronouncement is obviously needed, here goes: Python C
source code should be indented using tabs only.


(1) If 3rd party code is already written using a different style, it
    can stay that way, especially if it's a large volume that would be
    hard to reformat.  But only if it is consistent within a file or
    set of files (e.g. a 3rd party patch will have to conform to the
    prevailing style in the patched file).

(2) Occasionally (e.g. in ceval.c) there is code that's very deeply
    nested.  I will allow 4-space indents for the innermost nesting
    levels here.

Other C whitespace nits:

- Always place spaces around assignment operators, comparisons, &&, ||.

- No space between function name and left parenthesis.

- Always a space between a keyword ('if', 'for' etc.) and left paren.

- No space inside parentheses, brackets etc.

- No space before a comma or semicolon.

- Always a space after a comma (and semicolon, if not at end of line).

- Use ``return x;'' instead of ``return(x)''.

--Guido van Rossum (home page: http://www.python.org/~guido/)