Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.013 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'assign': 0.04; 'decent': 0.07; 'variables.': 0.09; 'am,': 0.12; 'skip:[ 20': 0.12; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:values': 0.16; 'url:manual': 0.16; 'this:': 0.16; 'wrote:': 0.16; 'wed,': 0.17; 'header:In-Reply-To:1': 0.22; 'variable': 0.24; 'aug': 0.24; 'separate': 0.28; 'message- id:@mail.gmail.com': 0.29; 'construct': 0.30; 'none,': 0.30; 'chris': 0.32; 'list': 0.32; 'probably': 0.33; 'to:addr:python- list': 0.33; '17,': 0.34; 'explicit': 0.34; 'object': 0.35; 'data.': 0.36; 'but': 0.37; 'some': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'php': 0.39; 'url:en': 0.39; 'to:addr:python.org': 0.39; 'url:net': 0.60; 'kind': 0.61; 'power': 0.63; 'learned': 0.73; 'url:php': 0.83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=XfXWa77tJJ1o8HB5IVyXv7Was4LZP+W+XnlIePs4YEI=; b=lZPnXunr1wch5cywAZ/sV8bLEi2pjrDvhzet+nKaKCJkzbwUB4cgL2xq0rRFjd5D1A I/2ONE4uugMC0rOZCiH+TdcpZorkvam28Gbvjy33bjKAGc+B884HZ+kGp1GUYaqZ+wt1 siWA+6i0PPqDq4WQKrsQdM0eRYBW0S1WdMQnI= MIME-Version: 1.0 In-Reply-To: <92d066ff-d0ee-432f-b512-1f2fa01ba681@a12g2000yqi.googlegroups.com> References: <92d066ff-d0ee-432f-b512-1f2fa01ba681@a12g2000yqi.googlegroups.com> Date: Wed, 17 Aug 2011 10:25:03 +0100 Subject: Re: CGI: Assign FieldStorage values to variables From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1313573106 news.xs4all.nl 23900 [2001:888:2000:d::a6]:48914 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:11670 On Wed, Aug 17, 2011 at 10:06 AM, Gnarlodious 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 Val2 You can probably do this with some kind of list comprehension, but I recommend against it, if this has come from a web form. You do NOT want end users having the power to set variables. Keep it in a separate object (such as 'form') such that you must always be explicit about fetching form data. PHP has learned the risks; here's a decent summary: http://www.php.net/manual/en/security.globals.php Chris Angelico