On Nov 9, 4:20 am, jlist9 <
jli...@gmail.com> wrote:
> Now that web.py uses return instead of print, is it possible to use the print
> statement to print to console for debugging?
If you mean unadorned print such as:
print 'hi'
then if you want to be a portable WSGI application the answer is no,
as WSGI adapters for CGI don't properly protect the stdout used by CGI
to communicate with the server and so by doing so you will screw with
the response from the application.
To try to encourage people to write portable WSGI applications,
mod_wsgi also places artificial restrictions on using stdin/stdout by
default. Because though most people couldn't be bother fixing code so
as to not use 'print' and instead direct it to 'stderr', that
restriction will be removed in mod_wsgi 3.0 however.
Read:
http://blog.dscpl.com.au/2009/04/wsgi-and-printing-to-standard-output.html
In summary, use 'print' if you want, but use:
import sys
print >> sys.stderr, 'hi'
as better anyway.
Graham