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

Terry Reedy tjreedy at udel.edu
Wed Mar 18 01:04:53 CET 2015


On 3/17/2015 2:31 PM, Nicholas Chammas wrote:
> The Zen of Python <https://www.python.org/dev/peps/pep-0020/> says:
>
>     There should be one— and preferably only one —obvious way to do it.
>
> Python already has a style guide in PEP 8
> <https://www.python.org/dev/peps/pep-0008/>. More importantly, from a
> practical standpoint, Python has automated third-party tools for
> checking and enforcing PEP 8 guidelines:
>
>   * |pep8| <https://pypi.python.org/pypi/pep8/>: Python style guide checker
>   * |autopep8| <https://pypi.python.org/pypi/autopep8/>: A tool that
>     automatically formats Python code to conform to the PEP 8 style guide

Except for idlelib and more recently turtledemo, the stdlib consists of 
*library* modules that define constants, mostly functions and classes, 
for import into and use by other libraries and applications.  Notice 
that the stdlib contains lib2to3, while the 2to3 application that uses 
lib2to3 is in /Tools/Scripts, along with other application scripts, 
mostly short, written by core developers.

pep8, autopep8, and similar applications do not belong in the stdlib. 
They are easily installed with, for instance, 'pip install autopep8'. 
The install process puts a startup file in /Scripts, which (for Windows 
at least) is on PATH (unlike /Tools/Scripts).  After installing, I 
entered 'autopep8 file.py' and it runs.

There is an issue on the tracker to add to the Idle IDE a gui frontend 
to pip, so beginners who use Idle will be able to manage (install, 
update, delete) 3rd-party apps like these without knowing about 'command 
lines' or having to remember pip options.  (There is also an issue to 
apply such apps to the contents of an Editor window.)

-- 
Terry Jan Reedy




More information about the Python-ideas mailing list