I get a construct like this:
form=FieldStorage(None, None, [MiniFieldStorage('name1', 'Val1'),
MiniFieldStorage('name2', 'Val2'), MiniFieldStorage('name3', 'Val3')])
Now how would I assign every variable name* its value?
lI did try locals().update(form) however I get
name2
-
I get a construct like this:
form=FieldStorage(None, None, [MiniFieldStorage('name1', 'Val1'),
MiniFieldStorage('name2', 'Val2'), MiniFieldStorage('name3', 'Val3')])
Now how would I assign every variable name* its value?
lI did try locals().update(form) however I get
name2
-
I should add that this does what I want, but something a little more
Pythonic?
import cgi, os
os.environ[QUERY_STRING] = name1=Val1name2=Val2name3=Val3
form=cgi.FieldStorage()
form
dict = {}
for key in form.keys(): dict[ key ] = form[ key ].value
dict
locals().update(dict)
name3
-- Gnarlie
--
On Wed, Aug 17, 2011 at 10:06 AM, Gnarlodious gnarlodi...@gmail.com wrote:
I get a construct like this:
form=FieldStorage(None, None, [MiniFieldStorage('name1', 'Val1'),
MiniFieldStorage('name2', 'Val2'), MiniFieldStorage('name3', 'Val3')])
when I need to assign the variable name2 the value
On Wed, Aug 17, 2011 at 10:19 AM, Gnarlodious gnarlodi...@gmail.com wrote:
import cgi, os
os.environ[QUERY_STRING] = name1=Val1name2=Val2name3=Val3
form=cgi.FieldStorage()
form
dict = {}
for key in form.keys(): dict[ key ] = form[ key ].value
You could probably use a list comp for this,
I should add that this does what I want, but something a little more
Pythonic?
import cgi, os
os.environ[QUERY_STRING] = name1=Val1name2=Val2name3=Val3
form=cgi.FieldStorage()
form
dict = {}
for key in form.keys(): dict[ key ] = form[ key ].value
dict
locals().update(dict)
name3
-- Gnarlie
--
On Wed, 17 Aug 2011 02:06:31 -0700, Gnarlodious wrote:
I get a construct like this:
form=FieldStorage(None, None, [MiniFieldStorage('name1', 'Val1'),
MiniFieldStorage('name2', 'Val2'), MiniFieldStorage('name3', 'Val3')])
Now how would I assign every variable name* its value?
Don't do
On Wed, Aug 17, 2011 at 2:19 AM, Gnarlodious gnarlodi...@gmail.com wrote:
I should add that this does what I want, but something a little more
Pythonic?
import cgi, os
os.environ[QUERY_STRING] = name1=Val1name2=Val2name3=Val3
form=cgi.FieldStorage()
form
dict = {}
for key in
On Aug 17, 3:25 am, Chris Angelico wrote:
You do NOT
want end users having the power to set variables.
Thanks for the warning, I can see I will need to quarantine the form
input. And update() is out of the question.
-- Gnarlie
http://Gnarlodious.com/
--