[Tutor] Re: Translating to Python [perl --> python]
Kyle Babich" <email@example.com
Tue, 2 Jul 2002 13:59:40 +0000
Ok, well then something is still wrong because I'm still getting syntax
errors that I can't figure out. Is there a python tutorial that is
more like cgi101.com (only python)? (Ie. including source codes, live
working examples, and different sections for different commands)
Btw, here is the code again:
print "Content-type: text/html\n\n"
form = cgi.FieldStorage()
c = form['c'].value
except KeyError :
c = ""
content = c
if c == 'abc':
content = "abc123"
elif c == 'def':
content = "def456"
print "error: content failed\n"
file = open("text.txt")
text = file.read()
<br> <br> <br>
""" % vars()
It says there is an error near except KeyError: but I've never used
python before so I don't know what to change.
On Tue, 02 Jul 2002 09:06:06 -0400, "Lloyd Kvam"
> (I presume Danny is asleep by this time.)
> Simply delete the two lines that contain cgitb references, or make
> them comments:
> #import cgitb
> cgitb ONLY comes into play if your script fails and raises an
> You can omit cgitb without affecting your normal processing.
> Kyle Babich wrote:
> > I would like to do the entire thing without cgitb because I don't have
> > the module and I don't want to try to convincing my host to install it.
> > Is it possible to do it without cgitb?
> > On Tue, 2 Jul 2002 01:16:11 -0700 (PDT), "Danny Yoo"
> > <firstname.lastname@example.org> said:
> >>On Mon, 1 Jul 2002, Kyle Babich wrote:
> >>>How could I do this without cgitb?
> >>Hi Kyle,
> >>Which part, exactly, would you like to do without the 'cgitb' traceback
> >>module? cgitb modifies the programming environment slightly so that
> >>raised exceptions give nicely formatted error messages back to the web
> >>Try commenting the cgitb lines first, and deliberately introduce a
> >>error in the script --- you'll notice that the web server doesn't
> >>too much useful information back to the user (although it will be in
> >>error log). On Apache, a bug in a CGI script brings up the
> >>uninformative "Internal Server Error" page.
> >>Afterwards, uncomment the cgitb-related lines and try again, and you'll
> >>see a difference. It's not mandatory, but it is pretty useful. I
> >>keep 'cgitb' on because it's such a nice debugging tool, and looks
> >>than having to do a:
> >> tail -f /var/log/apache/error.log
> >>which would be an alternative way of watching script problems.
> >>If you have more questions, please feel free to ask! By the way, it
> >>sounds like you're coming from a Perl background. How much Perl do you
> >>know already? We can tailor our answers to take advantage of your
> >>experiences in other languages, if that would be helpful for you.
> >>Good luck!
> > _______________________________________________
> > Tutor maillist - Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
> Lloyd Kvam
> Venix Corp.
> 1 Court Street, Suite 378
> Lebanon, NH 03766-1358