Brython - Python in the browser
Duncan Booth
duncan.booth at invalid.invalid
Fri Dec 21 08:14:15 EST 2012
More information about the Python-list mailing list
Fri Dec 21 08:14:15 EST 2012
- Previous message (by thread): Brython - Python in the browser
- Next message (by thread): Brython - Python in the browser
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Pierre Quentel <pierre.quentel at 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
- Previous message (by thread): Brython - Python in the browser
- Next message (by thread): Brython - Python in the browser
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list