Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.python
Re: Redirecting STDOUT using C calls.
Tom Gaudasinski
12/30/2007 10:04:00 PM
Christian Heimes wrote:
> Tom Gaudasinski wrote:
>
>> Greetings,
>> I'm trying to redirect python's stdout to another location. The
>> reason for this is that I'm embedding python in an application. Now,
>> originally my code was developed for Linux and that did not require
>> redirection due to the fact that every X11 application can have an
>> STDOUT associated with it. I then proceeded to take interest in making
>> my code portable and looked at compiling it on windows, however Win32
>> GUI applications are not given an STDOUT by default. One has to first
>> AllocConsole() and then reassign the handles using magic tokens
>> "CON(IN|OUT)$" such as freopen("CONOUT$", "w", stdout). I like to keep
>> code clean and would like to stick to the C API as much as possible.
>>
>
> Why don't you use the appropriate C api to redirect the standard streams?
>
> freopen("filename", "w", stdout);
>
> See
>
http://www.gnu.org/software/libc/manual/html_mono/libc.html#Standa...
>
> Christian
>
>
That is what I will be using in my final solution, however it makes no
difference for exemplary purposes in the samplecode i supplied. Using
freopen() still causes an invalid access exception exception in Windows.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Redirecting STDOUT using C calls.
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password