Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!news.mixmin.net!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'detect': 0.07; 'nicely': 0.07; 'ugly': 0.07; 'predefined': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'url:github': 0.09; 'way:': 0.09; 'elements,': 0.16; 'factory': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'notably': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'side.': 0.16; 'typos': 0.16; 'url:py': 0.16; 'wrote:': 0.18; 'module': 0.19; 'stefan': 0.19; 'thu,': 0.19; 'seems': 0.21; 'creating': 0.23; 'header:User- Agent:1': 0.23; 'looks': 0.24; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'trivial': 0.31; 'subject:with': 0.35; 'case,': 0.35; 'received:84': 0.35; 'there': 0.35; 'easily': 0.37; 'nov': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'blank': 0.60; 'ian': 0.60; 'lower': 0.61; 'tag': 0.61; 'simply': 0.61; '20,': 0.68; 'capital': 0.73; 'url:master': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Stefan Behnel Subject: Re: Working with HTML5 documents Date: Thu, 20 Nov 2014 21:10:09 +0100 References: <69c8db11-5928-4978-a0ca-0cd042f0febb@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-053-082.084.056.pools.vodafone-ip.de User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.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: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416514228 news.xs4all.nl 2842 [2001:888:2000:d::a6]:51398 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81119 Ian Kelly schrieb am 20.11.2014 um 20:44: > On Thu, Nov 20, 2014 at 12:02 PM, Stefan Behnel wrote: >> There's also the E-factory for creating (sub-)trees and a nicely objectish way: >> >> http://lxml.de/lxmlhtml.html#creating-html-with-the-e-factory > > That looks ugly with all those caps and also hard to extend. Notably > it seems to be missing any functions to build HTML5 elements, unless > those have been added in lxml 3.4. It's actually trivial to extend, and it's designed for it. The factory simply uses "__getattr__()", so you can ask it for any tag name. The predefined names in the builder.py module are mainly there to easily detect typos on user side. https://github.com/lxml/lxml/blob/master/src/lxml/html/builder.py If you don't like capital names for constants, just copy the module and change the tag names to lower case, or use the blank E-factory if you feel like it. Stefan