On Jul 8, 1:53 pm, bsneddon <[EMAIL PROTECTED]> wrote: > On Jul 8, 10:59 am, [EMAIL PROTECTED] (John J. Lee) wrote: > > > > > David <[EMAIL PROTECTED]> 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. -- http://mail.python.org/mailman/listinfo/python-list