Handling empty form fields in CGI

Paul Boddie paul at boddie.org.uk
Fri Jan 26 19:53:16 CET 2007

Christopher Mocock wrote:
> Bit of a python newbie so need a little help with a CGI script I'm
> trying to write. I've got it working fine as long as the fields of the
> form are filled in correctly, however I need to be able to accept blank
> entries. Therefore I want to convert any empty entries to an empty string.


> form = cgi.FieldStorage()

Try replacing this with...

form = cgi.FieldStorage(keep_blank_values=1)


More information about the Python-list mailing list