Monday, February 20, 2012

Applying PEP8 to python sources

Hi, sometimes I have to deal with poorly formatted python code. Does anyone
have a set of :substitute commands or a small script that prettifies to
at least some of PEP8 guidelines?

Specifically, I would like things like:

x=5 FIX TO: x = 5
BUT: func_call(x=5,
y=7) should be left as-is

x==y FIX TO: x == y, same for !=
( x, y , z ) FIX TO: (x, y, z); same for [ x, y, z ]
{ x : 1, y: 2 } FIX TO: {x: 1, y: 2}

Lines longer than specified length should be wrapped:

func_call(
......................................................................,
myvar)
TO:
func_call(
......................................................................,
myvar)


I think that covers the most hard to read, annoying to fix things..
-ak

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: