Pretty Printing Like Tidy for HTML
bsneddon
bsneddon at yahoo.com
Sun Jul 8 14:42:35 EDT 2007
On Jul 8, 1:53 pm, bsneddon <bsned... at yahoo.com> wrote:
> 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[0]+percentx*(self.xwidth)
>
> > > To:
>
> > > xp = self.uleft[0] + percentx * (self.xwidth)
>
> > > And other formatting issues.
>
> > Googled and found these; no idea if they're any good (latter is
> > commercial):
>
> >http://cheeseshop.python.org/pypi/PythonTidy/1.11
>
> >http://python.softalizer.com/
>
> > See also:
>
> >http://svn.python.org/view/python/trunk/Tools/scripts/reindent.py?vie...
>
> > John
>
> 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')
> >>> outFile.write(pSoup)
> >>> outFile.close()
Sorry, I answered the wrong question.
You wanted to format code not HTML.
More information about the Python-list
mailing list