ANN: XML builder for Python
stefan_ml at behnel.de
Thu Jul 3 21:04:47 CEST 2008
Walter Dörwald wrote:
> XIST has been using with blocks since version 3.0.
> Take a look at:
> from __future__ import with_statement
> from ll.xist import xsc
> from ll.xist.ns import html, xml, meta
> with xsc.Frag() as node:
> with html.html():
> with html.head():
> +html.title("Example page")
> with html.body():
> +html.h1("Welcome to the example page")
> with html.p():
> +xsc.Text("This example page has a link to the ")
> +html.a("Python home page", href="http://www.python.org/")
> print node.conv().bytes(encoding="us-ascii")
Interesting. Is the "+" actually required? Are there other operators that make
sense here? I do not see what "~" or "-" could mean.
Or is it just a technical constraint?
I'm asking because I consider adding such a syntax to lxml as a separate
module. And I'd prefer copying an existing syntax over a (badly) home grown one.
More information about the Python-list