[Tutor] cgi.FieldStorage to int
kabads at gmail.com
Wed Sep 21 23:11:32 CEST 2005
On 9/21/05, Kent Johnson <kent37 at tds.net> wrote:
> 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')
Ok - thanks for the tipoff Kent - the problem is now solved. My
timestable was returning as a list, as it was being populated in a
loop (for each question in the times table). Once I moved it outside
of the loop, the int(form.getvalue('timestable') works fine.
PGP key: 0x7111B833
More information about the Tutor