Python Source Code Beautifier

Franz Steinhaeusler franz.steinhaeusler at gmx.at
Tue Feb 27 03:45:42 EST 2007


Hello, I did not find any reasonable pyhton source code beautifier
program (preferable gui).

Some would ask why? Program it immediatly good.

(BTW: Would be a nice project, if I would have more spare time).

Ich have some foreign source, which are programed in a way
I don't like, so I would like to have a tool, which automatically
processes following options:


Use Spaces, size: 4
convert structs like: if (a > b):   to   if a > b:
fill in spaces, but not in functions between operators:

a+=1 => a += 1
p(t + 1) => p(t+1)

convert:

self.scriptcount = self.scriptcount + 1 => self.scriptcount += 1

from "is" to "==" and "is not" to "!=" (ok a find replace could do that
easily also), but in a program that would be more comfortable.

break long lines (in a reasonable way)

make from:
if len(string) > 0: => if string:
and 
if if len(string) < 1 orr if string == ""  => if not string

detect mixed line ending
detect tabs mixed with space
trim trailing whitespaces.

....
....


Is there such a tool around?

Running Pylint or Pycheck automatically afterwards
would be the coronation. :)



More information about the Python-list mailing list