Embedded python: printing exceptions to a file?

Gernot Hillier ghillie at suse.de
Sun Jan 5 08:42:43 EST 2003


Hi!

I use embedded python in my application and I'm really enthusiastic about it 
- the API is really well designed, thx. :-)

But now I have a small problem - I want to log errors from python scripts 
running in the embedded interpreter to a log file. 

All I found so far is PyErr_Print() which prints to sys.stderr.

I looked at its implementation - hoping to find a small function where I 
just could change sys.stderr to some open file and copy it to my 
application - but it seems to be rather complex so I think it's not wise to 
copy and modify all this code... :-((

So I see two ways:

- Perhaps there's a function provided which already provides an alternative 
to PyErr_Print()?

- Is there any easy & recommended way to let sys.stderr point to another 
open file object?

<OT>
I just wonder if it would be wise to splitup this newsgroup into some more 
specific subjects like (just suggestions)
- Python main (questions regarding the core Python functionality)
- Python-Newbie (installing, troubleshooting simple scripts, ...)
- Embedding/Extending python questions
- Additional modules
- ...

I really would like to read this group more actively - but it contains 
simply too much mails and too much things I'm not interested in...
</OT>

TIA!

-- 
Ciao,

Gernot




More information about the Python-list mailing list