Pretty Printing Like Tidy for HTML
bsneddon at yahoo.com
Sun Jul 8 19:53:54 CEST 2007
On Jul 8, 10:59 am, j... at pobox.com (John J. Lee) wrote:
> David <dwarnol... at suddenlink.net> writes:
> > Is there a pretty printing utility for Python, something like Tidy for
> > HTML?
> > That will change:
> > xp=self.uleft+percentx*(self.xwidth)
> > To:
> > xp = self.uleft + percentx * (self.xwidth)
> > And other formatting issues.
> Googled and found these; no idea if they're any good (latter is
> See also:
I did this useing the BeautifulSoup module.
Used it on XML created by msWord which had no formating was
all on one line.
>>> import BeautifulSoup
>>> soupStr = open('c:/data/quotes.xml').read()
>>> soup = BeautifulSoup.BeautifulSoup(soupStr)
>>> pSoup = soup.prettify()
>>> outFile = open('c:/data/quotesTidy.xml','w')
More information about the Python-list