Altering 'print'/mod_python

Jeff Davis jdavis at empires.org
Mon May 14 00:35:09 EDT 2001


        I have a webserver running mod_python and I would like it to execute 
python scripts (kind of like mod_perl or php). I basically made the python 
handler script call execfile(req.filename). I am not sure this is the best 
method. 
        Anyway, when inside the python script that is called by execfile you
have to use req.write() to print stuff. Is there a way to access the print 
statement directly so that when someone says print it calls req.write 
rather than printing to a file object?

        Any advice here would be appreciated, I am certainly not confident
that I am on the right track.

Regards,
        Jeff



More information about the Python-list mailing list