embedded: redirecting stdout before you call Py_Initialize

Jon K Hellan hellan at acm.org
Thu Mar 2 22:47:31 CET 2000


"Warren Postma" <embed at geocities.com> writes:

> [probably a FAQ, I searched the Python archives but couldn't find this exact
> thing anywhere...]
> 
> How do you redirect stdout to your own place, such as a Win32 anonymous
> pipe, before you even call Py_Initialize?  Is the key to redirect C's
> stdout? How do you do that?
> 
> I already know once Python is initialized you can reassign it's stdout
> object but that doesn't help me because by that point I've already missed
> any errors or output written while Py_Initialize was trying to import
> exceptions.py or site.py

I may be off base, but I did not think Py_Initialize wrote anything to
stderr at all. You have to make it print out using PyErr_Print. You
can redirect before that call.

What am I missing?

Jon



More information about the Python-list mailing list