Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'python': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'snippet': 0.09; 'subset': 0.09; "'))": 0.16; "'hello": 0.16; "(it's": 0.16; 'booth,': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'url:py': 0.16; 'url:svn': 0.16; 'wrote:': 0.17; 'stefan': 0.17; 'typing': 0.17; '>>>': 0.18; 'import': 0.21; 'new,': 0.22; 'this:': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'skip:b 30': 0.27; 'tree': 0.27; 'header:X -Complaints-To:1': 0.28; 'code': 0.31; 'implement': 0.32; 'received:84': 0.32; 'to:addr:python-list': 0.33; 'skip:d 20': 0.34; 'something': 0.35; 'there': 0.35; 'received:org': 0.36; 'url:org': 0.36; 'modules': 0.36; 'totally': 0.36; 'why': 0.37; 'subject:: ': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'url:public': 0.62; 'world': 0.63; 'received:arcor-ip.net': 0.84; 'received:pools .arcor-ip.net': 0.84; 'route': 0.84; 'ugly,': 0.84; 'available:': 0.91; 'url:sandbox': 0.95 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Stefan Behnel Subject: Re: Brython - Python in the browser Date: Fri, 21 Dec 2012 14:34:01 +0100 References: <50D256B3.4070709@udel.edu> <96edb672-dabd-4ab8-9e7c-3fa7f4a91437@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: dslb-084-056-036-199.pools.arcor-ip.net User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1356096867 news.xs4all.nl 6867 [2001:888:2000:d::a6]:51711 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:35289 Duncan Booth, 21.12.2012 14:14: > Pierre Quentel 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? >> >> Because the tree implementation in ElementTree or other tree modules >> in Python require a lot of typing and parenthesis >> >> To produce the HTML code >> >>
hello world
>> >> 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) > '
Hello world
' For which there even happens to be an ElementTree implementation available: http://svn.effbot.org/public/stuff/sandbox/elementlib/builder.py (It's not like I made this up ...) Stefan