Pythonic way of web-programming

David Abrahams dave at boost-consulting.com
Tue Apr 22 22:35:43 EDT 2003


bob at redivi.com (Bob Ippolito) writes:

> David Abrahams <dave at boost-consulting.com> wrote in message news:<848yu3o5o6.fsf at boost-consulting.com>...

>> 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.
>
> well, in our implementation (off the top of my head) these are valid:
>
> xml.sometag(_class = 'value2', attr1='value1')['contents']
> xml.sometag({'class':'value2'}, attr1='value1')['contents']
> xml.sometag('class="value2"', attr1='value1')['contents']
> xml.sometag(('class', 'value2'),), attr1='value1')['contents']
>
> The preferred is the first, it's easiest.  It's assumed that you will
> never want an attribute that actually starts with an underscore.  If
> you do (probably never), you'll have to use one of the other three
> options.

Hey, thanks for piping up, Bob!  If you've got an implementation of
this, you must be the same Bob who sat on the couch at PyCon and coded
this stuff up while Donovan Preston and I were designing the
syntax... you sure were a Python-coding machine!  A pleasure to meet
you; I never caught your last name.  I guess if you still have an
implementation, it's still working out for you... (?)

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Python-list mailing list