Order of keyword arguments

Skip Montanaro skip at mojam.com
Sun Nov 21 15:09:24 EST 1999


    Andres> I want to have my cake and eat it too! I thought this would be a
    Andres> way of keeping the flexibity of keyword arguments but also pass
    Andres> information along on how the calling function wants the items
    Andres> returned. For example, an HTML form could be called with a
    Andres> variable number of input tags and you want to render the HTML in
    Andres> the same order that they were used to call the function.

I solved this in one instance by giving all the input tag names names like
XXXtagname, where XXX is a zero-padded number.  The order of display is
determined by the form's author, so you could have

    001name
    002address
    003address
    004city
    005state

then in the cgi handler you simply sort them, then strip the first three
characters. 

Another thing to check if you have access to it is the raw QUERY_STRING.  I
believe browsers are supposed to (or at least do by convention) assemble the
string based upon the order of arguments in the form.  That way you can have
two fields named "address" and know that the order you see will be the same
as the order in which the user typed their street address and suite number.

Skip Montanaro | http://www.mojam.com/
skip at mojam.com | http://www.musi-cal.com/
847-971-7098   | Python: Programming the way Guido indented...





More information about the Python-list mailing list