Pythonic way of web-programming

David Abrahams dave at
Tue Apr 22 00:18:49 CEST 2003

Mark E. <snowball3 at> writes:

> David Abrahams <dave at> wrote:
>>    xml.sometag(attr1="value1", attr2="value2", ...)[ "contents" ]
> Of course there are always corner cases to deal with. For example, what's a good way
> to handle XHTML's 'class' attribute?
> xml.sometag(class="css_class_name")["contents"]
> won't work.
> One could map 'foo_' to 'foo' to handle conflicting names used in xml/html, or allow
> a dictionary to serve the same purpose:
> xml.sometag({"attr1" : "value1", "class" : "value2"})["contents"]

Sure, you have lots of options. Also:

    xml.sometag(class_("value2"), attr1 = "value1")["contents"]

    xml.sometag({'class':"value2", 'while':"value3"}, attr1 = "value1")["contents"]

    xml.sometag(attr1 = "value1", _ = {'class':"value2", 'while':"value3"})["contents"]

it's all in the fun of designing domain-specific sublanguages.

Dave Abrahams
Boost Consulting

More information about the Python-list mailing list