Spacing conventions

Chris Angelico rosuav at gmail.com
Wed Sep 27 04:19:05 EDT 2017


On Wed, Sep 27, 2017 at 6:10 PM, Thomas Jollans <tjol at tjol.eu> wrote:
> Personally I've found that my preferred tool, the Anaconda plugin for
> Sublime Text, sometime gets PEP 8 operator spacing wrong, and complains
> operators without spaces even where PEP8 explicitly recommends not using
> spaces. Read PEP 8, follow it if possible, but use your best judgement.
> Readability is important, blindly following your IDE's advice not so much.

And most importantly, read this section:

https://www.python.org/dev/peps/pep-0008/#a-foolish-consistency-is-the-hobgoblin-of-little-minds

This is the single most important recommendation in the document. Next
most important is the one immediately before it - the introduction -
which specifically states that this is the style guide for *the
standard library*. It's not a document which governs YOUR code, unless
you specifically choose it to be.

That said, though, it does reflect a lot of commonly-held views on
what's good style for Python code. And in the original examples, I
agree with PEP 8 on all points - no space before colon, no space
inside brackets, and generally yes space around the operator.

ChrisA



More information about the Python-list mailing list