Like f [ key ].value when f .has_key( key ), otherwise returns default. getvalue is slightly less convenient than methods getfirst or getlist; the only reason to use getvalue is if your script must remain compatible with old versions of Python, since methods getfirst and getlist were introduced in Python 2.2.

An instance f of class FieldStorage supplies the following attributes:


The Content-Disposition header, or None if no such header is present


A mapping of all the options in the Content-Disposition header, if any


A mapping of all headers, normally an instance of the rfc822.Message class covered in Chapter 21


A file-like object from which you can read the control’s value, if applicable; None if the value is held in memory as a string, as happens for most controls


The filename as specified by the client, for file controls; otherwise None


The name attribute of the control, or None if no such attribute is present


The Content-Type header, or None if no such header is present


A mapping of all the options in the Content-Type header, if any


The control’s value as a string; if f is keeping the control’s value in a file, then f implicitly reads the file into memory each time you access f .value

In most cases, attribute value is all you need. Other attributes are useful for file controls, which may have very large values and metadata such ...

Get Python in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.