emitting HTML and XML in Python

Kragen Sitaker kragen at dnaco.net
Wed Sep 27 04:58:09 EDT 2000


In article <kuem2670hn.fsf at lasipalatsi.fi>,
Erno Kuusela  <erno-news at erno.iki.fi> wrote:
>>>>>> "Kragen" == Kragen Sitaker <kragen at dnaco.net> writes:
>
>    Kragen> stringtest(xml.a('hello', href='http://www.oclc.org/'),
>    Kragen> '<a href="http://www.oclc.org/">hello</a>')
>
>this looks quite similar to what Andy Dustman's HyperText package
>produces. it lives at <URL:http://dustman.net/andy/python>.
>maybe you should merge efforts?

It is very similar; thanks for the pointer!  The HyperText module is
much more SGMLish (DTD-driven, upper-case, harder to adapt to new
different DTDs), while what I posted is much more XMLish (stupid,
simpleminded, lower-case); HyperText has many more features
(DTD-drivenness, multiple content arguments, writeto, indented output,
smart attribute name translation, entity-encoding, URL-encoding, form
encoding, CSS styles, SGML comments, real documentation), and totals
1481 lines of .py, while what I posted totals 65.

There might be times you'd want to use the stupid thing instead of the
smart one.

Andy is, of course, welcome to use the little XHTML thingy I posted if
he thinks it will make his life easier; I did disclaim any copyright in
it, and I hope lots of people find it useful.  :)

I wish I knew how __import__ worked in 1.5.2; then perhaps I could make
the toy module I posted just as convenient to use as HyperText.  The
2.0 documentation certainly seems to suggest you could import things
generated on the fly.
-- 
<kragen at pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Perilous to all of us are the devices of an art deeper than we ourselves
possess.
                -- Gandalf the Grey [J.R.R. Tolkien, "Lord of the Rings"]



More information about the Python-list mailing list