Pierre Quentel <pierre.quen...@gmail.com> wrote: >> If that's your intention, then instead of coming up with something >> totally new, unpythonic and ugly, why not take the normal Python >> route and implement a subset of the ElementTree API? >> >> Stefan > Because the tree implementation in ElementTree or other tree modules > in Python require a lot of typing and parenthesis > > To produce the HTML code > ><DIV>hello <B>world</B></DIV> > > these modules require writing something like > > div = Tag('DIV') > div.appendChild(TextNode('hello ')) > b = Tag('B') > b.appendChild(TextNode('world')) > div.appendChild(b) > doc.appendChild(div)
Or you can do something like this: >>> from lxml.html.builder import * >>> snippet = DIV("Hello ", B("world")) >>> etree.tostring(snippet) '<div>Hello <b>world</b></div>' > > With the tree syntax proposed in Brython it would just be > > doc <= DIV('hello '+B('world')) > > If "pythonic" means concise and readable, which one is more pythonic ? > The one that doesn't do unexpected things with operators. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list