Re: Python coding style

Doug Evans
2010-10-08T21:20:05Z

On Wed, Oct 6, 2010 at 3:25 PM, Tom Tromey <tromey@redhat.com> wrote:
> Doug> Can we, at least as a first pass, adopt this?
> Doug> http://google-styleguide.googlecode.com/svn/trunk/pyguide.html
>
> It is ok with me.  I read through it and I thought it seemed reasonable
> enough.
>
> Can you say how it compares to PEP 8?
>
>    http://www.python.org/dev/peps/pep-0008/
>
> They seemed basically compatible to me, but I only spent a few minutes
> with each.

AIUI there are a few incompatibilities.
e.g. pep says importing functions is ok, google style guide says only
import packages/modules.
I'm by no means an expert.

I think Google's guide specifies more, and specifies the reasons more.
We *could* reference both, and a blanket statement that X wins when
there's a conflict.
And then provide a supplement for gdb-specifics.
Easier than writing our own from scratch.

> Since you are more familiar with it, would you mind doing a little extra
> review for changes to .py files for a while?  Some of the rules are
> different enough from GNU C that it will take some getting used to;
> e.g., the hanging indentation rule.

If you wish.

> A couple specific exceptions:
>
> * We shouldn't use the #!/usr/bin/env thing

For my own education, why not?
[So I can document it in the style guide.]

> * We should use FIXME instead of TODO, as the former is already gdb
>  practice

Yeah.

> Phil> My deeply biased and very personal ideology her e is if how emacs
> Phil> handles it.
>
> The defaults are mostly ok.  You'll need to set indent-tabs-mode to nil
> in these buffers (though even this happens automatically with the
> default settings).

We should provide an emacs py mode that specifies our style.