CGI: Assign FieldStorage values to variables

Gnarlodious gnarlodious at gmail.com
Wed Aug 17 11:19:22 CEST 2011


I should add that this does what I want, but something a little more
Pythonic?

import cgi, os
os.environ["QUERY_STRING"] = "name1=Val1&name2=Val2&name3=Val3"
form=cgi.FieldStorage()

form

dict = {}
for key in form.keys(): dict[ key ] = form[ key ].value

dict
locals().update(dict)
name3

-- Gnarlie



More information about the Python-list mailing list