[Tutor] FW: Forms

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Tue Jul 19 03:03:52 CEST 2005



On Mon, 18 Jul 2005, gordnjen wrote:

> There was an error with your script and it didn't exit properly.
>
> This was its output:
>
>   File "/home/jgates/public_html/Fifthone.py", line 12
>
>     print form int(["red1"].value),"%"
>
>                  ^
>
> SyntaxError: invalid syntax



Hi Jennine,

Ok, it looks like you're using the cgi.FieldStorage class and you're
trying to look up the 'red1' value in the form.


But it also looks like you have some int() stuff there that I'm not quite
sure about yet.  Is it ok if we strip that out for the moment, and
simplify things to something smaller?  (We can talk more about int()
later.)

######
print form(["red1"].value),"%"
######

If you do this, you won't get a SyntaxError, although you'll probably get
a different kind of error.  *grin*



So let's look at this a bit more.  According to the documentation of the
'cgi' module, there's a :

    http://www.python.org/doc/lib/node467.html

you can ask a form for its values by using getfirst().  So the code above
would look like:

######
print form.getfirst('red1'), '%'
######

Try that and see if that works any better.



More information about the Tutor mailing list