[lxml-dev] altering the indent of the pretty output

Stefan Behnel stefan_ml at behnel.de
Wed Feb 4 20:53:42 CET 2009


Ronny Pfannschmidt wrote:
> i'm currently porting gazpacho (a wysiwyg gtk ui file editor) to lxml,
> unfortunately the pretty printer prints with an indent of 2 and in order
> to match the convention i need an indent of 4
> 
> is there any simple way to archive pretty dumping to a file with an
> indent of 4?

Apart from the already proposed XSLT serialisation, libxml2 does have a way
to set the indentation level. However, that is done globally at a
per-thread level and isn't currently exposed at lxml's API level.

I'd accept patches that support it for a single call to ET.write() and
tostring().

Stefan


More information about the lxml-dev mailing list