Embedding -- getting error/traceback information not to stderr?
Adrian Eyre
a.eyre at optichrome.com
Tue Jan 25 07:50:10 EST 2000
> >3) Set stderr to be stdout
> Well, I wanted the information to be in a variable in memory, which I can
> then send to the user (which isn't looking at stdout :) ).
Ah. I misunderstood what you needed.
I found this sort of thing to be quite useful, especially in cgi scripting:
import sys, traceback, string
def main(argv):
try:
all_my_code_here(argv[1])
return 0
except:
s = string.join(apply(traceback.format_exception, sys.exc_info()))
print s # Do what you like with it here
return 1
if __name__ == '__main__':
sys.exit(main(sys.argv))
--------------------------------------------
Adrian Eyre <a.eyre at optichrome.com>
http://www.optichrome.com
More information about the Python-list
mailing list