Catching error text like that shown in console?

gene tani gene.tani at gmail.com
Fri Dec 9 17:04:02 EST 2005


Peter A. Schott wrote:
> I know there's got to be an easy way to do this - I want a way to catch the
> error text that would normally be shown in an interactive session and put that
> value into a string I can use later.  I've tried just using a catch statement
> and trying to convert the output to string, but this doesn't always work.  I
> really don't have programs complex enough to do a lot of specific catching at
> this point - I just want to know:
>   1. something failed
>   2. here's the error output/traceback
>
> Anyone know how I can do this or if it's possible?  Didn't find anything doing a
> search so I figured I'd hit up the experts.
>
> Thanks.
>
> -Pete Schott

I don't have an exact answer for you, but since no one else replied:

look at subprocess module, and os.popen4()

http://docs.python.org/lib/os-newstreams.html#os-newstreams
http://docs.python.org/lib/module-subprocess.html
http://mail.python.org/pipermail/python-list/2005-October/305671.html

Hint: mentioning your O/S is pretty essential; for many issues, what
version of py and how you installed it also




More information about the Python-list mailing list