[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-list
Subject:    Re: parse_qs ... why dictionarykey : list ?
From:       Brian Donovan <lists () lophty ! com>
Date:       2002-07-31 18:58:06
[Download RAW message or body]

> (1.) Why does cgi's parse_qs return each of the param:value pairs in a
> querystring as a dictionary key and a list?
> 
> (2.) How does one format a query string so that lists can actually be
> passed to a Python script via querystring so that parse_qs will "see"
> them? [I've futzed around a bit but haven't stumbled on how it's done.]

I'll reply to my own posting since someone contacted me via email with 
the answer and it may benefit someone else searching the archives some day :

> It's perfectly legal to have more than one input item on an HTML form
> with the same name.  parse_qs returns its results as a list so that if
> there was more than one item with the same name in a querystring you can
> access each value.
> 
> For example, try:
> 
> foo.py?color=Red&color=Blue&color=Green

Thanks to Abe fettig (http://www.fettig.net) for the answer. :D

- brian


-- 
--------------------------------------------------------------------
Brian Donovan, web programmer / researcher
Lophty <http://www.lophty.com> [projects, snippets]
Monokrom <http://www.monokromatik.com> [commentary, writing]
--------------------------------------------------------------------
Namebrand, Corp <http://www.namebrandcorp.net>
--------------------------------------------------------------------

-- 
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic