Source formatting fixer?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Dec 14 17:16:15 EST 2007


En Fri, 14 Dec 2007 15:33:44 -0300, Bret <bret.wortman at gmail.com> escribió:

> The thing is, I'm not so much trying to fix indentation issues as
> spacing problems that affect readability but not program structure.
> All the indentation is fine, this is more trying to change things
> like:
>
> if ((one==two)and(three==four)):
>     a=b+42
>     c=Classname (a,b)
>     print "Class %s created"%c.__name__
>
> None of the above is wrong, it's just painfully ugly and given
> Python's natural beauty, it seems really wrong all the same....

PythonTidy http://pypi.python.org/pypi/PythonTidy may help, altough I feel  
it too aggressive sometimes.
Your example above is converted into this:

#!/usr/bin/python
# -*- coding: utf-8 -*-

if one == two and three == four:
     a = b + 42
     c = Classname(a, b)
     print 'Class %s created' % c.__name__

-- 
Gabriel Genellina




More information about the Python-list mailing list