Life cycle of a mod_python application and scope of global variables
Mongryong
Mongryong at sympatico.ca
Fri Jan 24 18:12:24 EST 2003
On Fri, 2003-01-24 at 13:30, Kyle Yancey wrote:
> Correction. The code should have been this.
>
> #!/usr/bin/env python
> from mod_python import apache
>
> def handler(req):
> req.content_type = "text/plain"
> req.send_http_header()
> req.write(i)
> i = i + 1
> return apache.OK
>
Well, the reason why this code doesn't work is because of the line:
i=i+1
'i' needs to be defined before this - you can't use a variable if it
hase already been defined. I think you're trying to do this:
i = 0
def handler(req):
...
...i = i + 1
Also, it's hard to post to your thread because you're using a fake
email.
More information about the Python-list
mailing list