[Tutor] Writing scripts and apps for Internet consumption

Timo timomlists at gmail.com
Sun Aug 1 10:12:32 CEST 2010


On 01-08-10 00:40, Eric Hamiter wrote:
> On Sat, Jul 31, 2010 at 4:48 PM, bob gailer <bgailer at gmail.com 
> <mailto:bgailer at gmail.com>> wrote:
>
>
>     Please post that code, and the URL you use to invoke it.
>
>
> test.py: this works on my laptop but not on the server
>
> http://pastebin.com/ChjUzLRU
Just a wild guess, but maybe it is failing on the following line:

with open("grocery_list.txt") as grocery_list:

The with statement was introduced in Python 2.5, and if I look at my own 
webhost, they are still with Python 2.4.
Make a script that prints the Python version (with sys.version_info or 
sys.version for example) or ask your webhost.

You can also put this on top of your script, so it shows you a nice 
Python traceback instead of an error:
import cgitb
cgitb.enable()


Cheers,
Timo


>
> test-working.py: this works on both laptop & server
>
> http://pastebin.com/iLNTrGdW
>
> both available for execution here:
>
> http://erichamiter.com/xkred27/
>
>
>     Do you import cgi?
>
>
> Yes.
>
>
>     There is a companion module (cgitb) that captures exceptions and
>     returns the traceback to the web browser.
>
>
> I tried that as well. I'm sure I'm missing something fundamental here, 
> but that's kind of obvious since I posted I don't know what I'm doing 
> in the first place! :)
>
> Thanks,
>
> Eric
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>    



More information about the Tutor mailing list