Python drives me mad...
Christian Tismer
tismer at tismer.com
Mon Mar 20 12:22:57 EST 2000
Boris Ottlewski wrote:
>
> Last attempt to get the result from python in embedded mode. (I am about to
> quit...)
>
> I do this:
>
> FILE *stream;
> char temp[8192];
> new_stdout = PyFile_FromString("c:\\freopen.out", "w");
> PySys_SetObject("stdout", new_stdout);
> file://PySys_SetObject("stderr", new_stdout);
----------------------------!!!!!!
What's this? Are you sure you are dealing with stdout?
> int res = PyRun_SimpleString("print 2\n");
> Py_XDECREF(new_stdout);
>
> This should print the "2" to the redirected stdout which is c:\freopen.out.
> But the file is empty!!!!!!!!!! and...I cant delete it, it is still locked
> (shouldnt Py_XDECREF close it?)
When is it empty: After your session is closed? Or while it is
running?
Py_DECREF doesn't close it, since you assigned it to the system
stdout variable. You just (correctly) removed your reference.
I guess it would work if you kept the old stdout and assigned it
back, or do an explicit close.
cheers - chris
p.s.: Please drop the NOSPAM from your postings.
We are all SMAP aware, and answering many emails
per day isn't possible when one has to edit the addresses.
--
Christian Tismer :^) <mailto:tismer at appliedbiometrics.com>
Applied Biometrics GmbH : Have a break! Take a ride on Python's
Kaunstr. 26 : *Starship* http://starship.python.net
14163 Berlin : PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF
we're tired of banana software - shipped green, ripens at home
More information about the Python-list
mailing list