Re: [Python-ideas] gofmt for Python: standardized styling as a language feature
On Thu, Mar 19, 2015 at 2:30 PM, Terry Reedy
On 3/19/2015 5:01 PM, Guido van Rossum wrote:
On Thu, Mar 19, 2015 at 1:40 PM, Terry Reedy
Having the guidelines numbered (id'ed), even though still regarded
as guidelines, could help communication. Checkers could then easily refer to specific guidelines.
I worry this will just encourage the nit-picky attitude more.
I agree that this is a possible negative.
I'll leave the rest of the discussion to other participants. It seems all possible POVs are well-represented.
Thanks for the link. I was specifically thinking of global
renamings to satisfy PEP 8's Naming Conventions. Idlelib has a mishmash of module and function/method name styles. (I might look and see what can be done with the undocumented (except as 'unstable') libe2to3.)
This feels hard to automate, because you don't know what names are part of an external specification.
Modernizing idlelib names, in relation to PEP 434, is a separate discussion.
I think that a quick "clean up whitespace" feature would be a nice
addition to IDLE, provided it's a user-selectable menu items (similar to the existing indent/dedent operations).
The Format menu now has 'Strip trailing whitespace', which may be new since you last looked. It needs to strip trailing blank lines, as reindent.py does, in addition to trailing whitespace on each line, to make files ready to commit to the cpython repository. Did you have in mind also doing within-line cleanups (as a separate menu entry)?
I probably spoke out of turn (I haven't really used IDLE in years). But I could imagine another command that did something like autopep8 on a selection, making sure the whitespace around various operators is consistent with PEP 8, fixing indentation levels, and even inserting/removing blank lines in certain cases. I'm not sure I would want it to automatically break long lines, as I often have very specific ideas about the best place to break a long line, which require understanding the meaning of the code. Have you used Emacs? The python-mode written by Tim Peters and maintained by Barry Warsaw has some pretty amazing reformatting capabilities (though I rarely use them, because my fingers automatically type correctly formatted code :-). -- --Guido van Rossum (python.org/~guido)
On Mar 19, 2015, at 04:55 PM, Guido van Rossum wrote:
Have you used Emacs? The python-mode written by Tim Peters and maintained by Barry Warsaw has some pretty amazing reformatting capabilities (though I rarely use them, because my fingers automatically type correctly formatted code :-).
I must admit to a long-standing lack of enthusiasm for Elisp hacking, so much of the recent credit for python-mode's development goes to Andreas Röhler. :) Simple additions of pyflakes (some folks like flake8) and whitespace-mode make python-mode really fantastic for quickly spotting questionable code. My fingers too are well-trained but sometimes my brain gets in the way, and then Emacs will clearly show me lines that need clean up. I'd like that better than something that automatically reformats my code. Cheers, -Barry
участники (2)
-
Barry Warsaw
-
Guido van Rossum