List comprehension and FieldStorage

Derek Basch dbasch at yahoo.com
Tue Apr 26 17:58:56 EDT 2005


Given this FieldStorage object:

FieldStorage(None, None, [MiniFieldStorage('Checkbox1', 'on'),
MiniFieldStorage('Checkbox2', 'on')])

I am trying to cgi.urlencode the FieldStorage object to POST to another
cgi script. The documentation for urlencode,
http://docs.python.org/lib/module-urllib.html , says that urlencode
takes a mapping object or a list of double tuples. I see that I could
use cgi.parse_qs and cgi.parse_qsl to create these object types. Should
I just use that or should I continue using FieldStorage? Also how would
I create an object of either type from a FieldStorage object? Here is
my attempt at creating the double tuple list (It sucks....I know):

print [(key, value) for key, value in form.keys() and form[key].value]

Thanks for the help,
Derek Basch




More information about the Python-list mailing list