Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Another way is using the <a href="http://codespeak.net/lxml/tutorial.html#the-e-factory" rel="nofollow noreferrer">E Factory</a> builder from lxml (available in <a href="http://effbot.org/zone/element-builder.htm" rel="nofollow noreferrer">Elementtree</a> too)</p> <pre><code>&gt;&gt;&gt; from lxml import etree &gt;&gt;&gt; from lxml.builder import E &gt;&gt;&gt; def CLASS(*args): # class is a reserved word in Python ... return {"class":' '.join(args)} &gt;&gt;&gt; html = page = ( ... E.html( # create an Element called "html" ... E.head( ... E.title("This is a sample document") ... ), ... E.body( ... E.h1("Hello!", CLASS("title")), ... E.p("This is a paragraph with ", E.b("bold"), " text in it!"), ... E.p("This is another paragraph, with a", "\n ", ... E.a("link", href="http://www.python.org"), "."), ... E.p("Here are some reserved characters: &lt;spam&amp;egg&gt;."), ... etree.XML("&lt;p&gt;And finally an embedded XHTML fragment.&lt;/p&gt;"), ... ) ... ) ... ) &gt;&gt;&gt; print(etree.tostring(page, pretty_print=True)) &lt;html&gt; &lt;head&gt; &lt;title&gt;This is a sample document&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1 class="title"&gt;Hello!&lt;/h1&gt; &lt;p&gt;This is a paragraph with &lt;b&gt;bold&lt;/b&gt; text in it!&lt;/p&gt; &lt;p&gt;This is another paragraph, with a &lt;a href="http://www.python.org"&gt;link&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Here are some reservered characters: &amp;lt;spam&amp;amp;egg&amp;gt;.&lt;/p&gt; &lt;p&gt;And finally an embedded XHTML fragment.&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload