Thanks for explaining! On Sun, Nov 8, 2009 at 7:17 PM, Graham Dumpleton <[email protected]> wrote: > > On Nov 9, 4:20 am, jlist9 <[email protected]> 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 > > >
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web.py" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/webpy?hl=en -~----------~----~----~----~------~----~------~--~---
