[Tutor] cgi.FieldStorage to int
kent37 at tds.net
Wed Sep 21 21:29:40 CEST 2005
Adam Cripps wrote:
> On 9/21/05, Kent Johnson <kent37 at tds.net> wrote:
>>Adam Cripps wrote:
>>>I'm trying to get a cgi.FieldStorage into an int.
>>>The input is in numeric form, as it is provided by an <option>
>>>drop-down box. However, when I try
>>>timestable = int(form.getvalue('timestable'))
>>>I get an error that the type is None - I guess this is because
>>>FieldStorage is a class. However, I've trawled around trying to get
>>>this field into an integer but without any luck.
Please post the exact error message including the stack trace. Also, what prints when you print form.getvalue('timestable')
>>My guess is that there is no 'timestable' parameter - are you sure you spelled it the same way in the form? Try adding
>>print >>sys.stderr, form.keys()
>>to the form, I think this will print a list of available parameters to the console.
> Great minds think alike, but alas I'm pretty sure it's not the issue -
> I've already checked whether timestable existed with:
> print "timestable is...", form.getvalue('timestable')
> and it displays fine.
> Tutor maillist - Tutor at python.org
More information about the Tutor