getfirst and re

MRAB python at mrabarnett.plus.com
Fri Jan 8 14:21:42 EST 2010


Victor Subervi wrote:
> On Fri, Jan 8, 2010 at 1:26 PM, Steve Holden <steve at holdenweb.com 
> <mailto:steve at holdenweb.com>> wrote:
> 
>     MRAB wrote:
>      > Victor Subervi wrote:
>      > [snip]
>      >>
>      >> Code snippet:
>      >>
>      >> def cgiFieldStorageToDict(fieldStorage):
>                                 ^^^^^^^^^^^^
>     Further hint ...
> 
>      >>   params = {}
>      >>   for key in fieldStorage.keys():
>      >>     params[key] = cgi.FieldStorage[key].value
>      >                     ^^^^^^^^^^^^^^^^^^^^^
>      > This is your problem.
> 
> 
> The problem is that I don't understand this code that I exactly copied 
> from a Web page tutorial. Can you folks point me to tutorials where I 
> can learn to comprehend this code? Specifically, the line in question. 
> How is it that one can code "params[key]" (what does that mean?) and the 
> other side, what does that mean
> 
If you got it from:

     Recipe 81547: Using a simple dictionary for CGI parameters
     http://code.activestate.com/recipes/81547/

then no, it wasn't "exactly copied". If you'd copy-and-pasted it then it
would've been correct, as well as much quicker to do...



More information about the Python-list mailing list