今日の収穫

  • lxml.htmlbuilder
  • lxml.builder

なんか MochiKit っぽい。

 """
 HTML specialisation of ``builder.py`` by Fredrik Lundh
 
 Usage::
 
     >>> from lxml.htmlbuilder import *
     >>> html = HTML(
     ...            HEAD( TITLE("Hello World") ),
     ...            BODY( CLASS("main"),
     ...                  H1("Hello World !")
     ...            )
     ...        )
 
     >>> import lxml.etree
     >>> print lxml.etree.tostring(html, pretty_print=True)
     <html>
       <head>
         <title>Hello World</title>
       </head>
       <body class="main">
         <h1>Hello World !</h1>
       </body>
     </html>
 
 """

lxml.etree.tounicode とかも使えそう。