1. Home
  2. Computing & Technology
  3. Python

Programming CGI With Python

From Al Lukaszewski, for About.com

4 of 4

Other Methods of Accessing Data

In addition to 'getvalue', the following methods may be used to access form data by field name:

  • form.getfirst Returns the first value found for a field by the given name
  • form.getlist Returns a list of all values found for a field by the given name. If no values are found, it returns an empty list.

In a case where each field name is unique, all three methods will return the same results. So the following will return the same data:

name = form.getvalue('name')
name = form.getfirst('name')
name = form.getlist('name')
The method 'getlist', however, will return a list of values. The others will simply return a string.

Explore Python
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Python
  4. Web Development
  5. Python CGI - Other Methods of Accessing Data With Python's CGI

©2009 About.com, a part of The New York Times Company.

All rights reserved.