[Python-ideas] gofmt for Python: standardized styling as a language feature

Terry Reedy tjreedy at udel.edu
Wed Mar 25 17:38:09 CET 2015


On 3/25/2015 8:42 AM, Eli Bendersky wrote:
>
>
> On Tue, Mar 17, 2015 at 8:29 PM, Eli Bendersky
> <eliben at gmail.com
> <mailto:eliben at gmail.com>> wrote:
>
>     Interesting coincidence :-)
>
>     We (at Google) are just on the verge of releasing an open-source
>     tool for auto-formatting of Python code. It should be posted to
>     Github within the next few days or weeks, under a permissive license
>     (Apache 2.0 or something similar).
>
>     The tool works like gofmt and clang-format (the C++/JS version
>     provided as part of the Clang toolchain) - it only acts on
>     whitespace and performs re-formatting of code (PEP-8 oriented for
>     Python but it's configurable). It does not rename
>     variables/classes/functions to conform to any particular style. The
>     algorithm is based on clang-format, and lib2to3 is used for the
>     parsing side - so it's very solid. We use it on Python 2 code
>     internally, but Python 3 support is also planned and should be easy.
>
>     We intend to keep actively developing the tool in the open and will
>     be happy to accept test cases, fixes and patches in general.
>
>     So stay tuned!
>
>
> https://github.com/google/yapf

yet-another-python-formatter

The so-called pep8 style in style.py has

# The number of spaces required before a trailing comment.
SPACES_BEFORE_COMMENT=1,

PEP8 actually says "Inline comments should be separated by at least two 
spaces from the statement.", which is what you have in the google style.

-- 
Terry Jan Reedy



More information about the Python-ideas mailing list