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

Nicholas Chammas nicholas.chammas at gmail.com
Thu Mar 19 15:32:02 CET 2015


OK, I hereby abandon this proposal. :)

To summarize the conclusion I believe this thread has arrived at:

   - An auto-styler needs to have wide community adoption before it can be
   considered for inclusion into the standard library.
   - Even then, adding stuff to the standard library at this point in
   Python’s life is generally a bad thing. Putting an auto-styler in the
   standard library would be a big burden on its maintainers and slow down
   improvements that could be made to it.
   -

   Ignoring that difficulty, there is also the problem of what “spec” to
   use for any such auto-styler. PEP 8 is an obvious choice, but it was
   written as a guide for humans, not a spec for programmatic implementation.
   Furthermore, there are doubts about PEP 8’s utility as the basis for a
   universal auto-styler, as it was intended for code specifically in the
   Python standard library.
    -

   Let a thousand auto-stylers bloom outside the standard library.

Some final responses to various people’s comments:

On Wed, Mar 18, 2015 at 4:38 PM, Andrew Barnert <abarnert at yahoo.com> wrote:

But that implies that it's worth someone making a spec out of PEP 8. That
> implies going through PEP 8, getting a sense of what parts are
> (unambiguously and uncontroversially) mechanizable, and reorganizing and
> minimally rewriting it to get that sense across. Having numbered rules, and
> named anchors for each one in the document (or at least to narrower
> sections, so you can link to something more specific than "Programming
> Recommendations") would also be helpful.

This is an excellent point and one I did not consider.

On Wed, Mar 18, 2015 at 6:17 PM, Terry Reedy <tjreedy at udel.edu> wrote:

PEP 8 is Guido's view on how new CPython stdlib code should be written,
> with input from other core developers.  "This document gives coding
> conventions for the Python code comprising the standard library in the main
> Python distribution."

Good point. For my all my talk about PEP 8, I missed this key point. Of
course, it should be noted that PEP 8 is being used by all kinds of people
for stuff outside of stdlib, but then again as you pointed out people are
also putting together their own style guides.

On Wed, Mar 18, 2015 at 6:17 PM, Terry Reedy <tjreedy at udel.edu> wrote:

(Note that autoPEP8 only changes whitespace, which is a small part of PEP 8
> recommendations, and the safest aspect of code to change.)
>
Minor point: autopep8 can do more than just whitespace changes with the
--aggressive flag
<https://pypi.python.org/pypi/autopep8/#more-advanced-usage>.

On Wed, Mar 18, 2015 at 7:21 PM, Terry Reedy <tjreedy at udel.edu> wrote:

We should be careful about adding anything.  When we do, we should add
> libraries, not applications.  We should especially not officially endorse
> one of many opinion-based competitors.

I have come around to this view.

On Wed, Mar 18, 2015 at 7:30 PM, Eli Bendersky <eliben at gmail.com> wrote:

Basically the idea is "forget about formatting your code, just run it
> through the tool", which is a similar philosophy as gofmt (and
> clang-format) and has been hugely successful for those tools/languages.
>
Sounds good. I’m looking forward to seeing it released. As I said in an
earlier email, I think any part of the development process we automate away
is a good thing (stdlib inclusion or not notwithstanding).

Nick
​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150319/163e78de/attachment-0001.html>


More information about the Python-ideas mailing list