[Tutor] Elementtree and pretty printing in Python 2.7

Knacktus knacktus at googlemail.com
Fri Aug 20 09:49:26 CEST 2010

Hi guys,

I'm using Python 2.7 and the ElementTree standard-lib to write some xml.

My output xml has no line breaks! So, it looks like that:

<Items><Project creation_date="heute"/></Items>

instead of something like this:

     <Project creation_date="heute"/>

I'm aware of lxml which seems to have a pretty print option, but I would 
prefer to use the standard-lib ElementTree which seems not to have a 
feature like this.

Do I miss something using the ElementTree-lib or is it bug?



More information about the Tutor mailing list