Hi,
Using an embedded interpreter, how do I change it's default output streams
(specifically the one used by PyErr_Print() which I'm guessing is the
default error stream)?
Cheers,
Ira 7 1989
"Ira" <sh******@gmail.com> writes: Using an embedded interpreter, how do I change it's default output streams (specifically the one used by PyErr_Print() which I'm guessing is the default error stream)?
It looks as though it writes to stderr unconditionally. But most of
the reasons for ended up in PyErr_Print can be intercepted at a higher
level (I think -- I mean sys.excepthook & co here).
Cheers,
mwh
--
ARTHUR: Yes. It was on display in the bottom of a locked filing
cabinet stuck in a disused lavatory with a sign on the door
saying "Beware of the Leopard".
-- The Hitch-Hikers Guide to the Galaxy, Episode 1
OK let me rephrase,
the standard error stream (and if I'm not mistaken also the one that
PyErr_Print() writes to) is the python object sys.stderr. Now say I'd go
ahead and write the following in python...
SomeNewStreamOrFileOrWhateverItIs = new stream
sys.stderr = SomeNewStreamOrFileOrWhateverItIs
I can go ahead and do the exact same thing from the C source code. All I
need to do is to figure out how to wrap a c-style FILE* with a PyObject, And
PySys_SetObjet("stderr", newstream);
I'm very new to python so that might be nonsense but it appeals to my
programmer's common sense. Can anyone tell me how to do this?
"Michael Hudson" <mw*@python.net> wrote in message
news:m2************@82-33-185-193.cable.ubr01.azte.blueyonder.co.uk... "Ira" <sh******@gmail.com> writes:
Using an embedded interpreter, how do I change it's default output streams (specifically the one used by PyErr_Print() which I'm guessing is the default error stream)?
It looks as though it writes to stderr unconditionally. But most of the reasons for ended up in PyErr_Print can be intercepted at a higher level (I think -- I mean sys.excepthook & co here).
Cheers, mwh
-- ARTHUR: Yes. It was on display in the bottom of a locked filing cabinet stuck in a disused lavatory with a sign on the door saying "Beware of the Leopard". -- The Hitch-Hikers Guide to the Galaxy, Episode 1 -- http://mail.python.org/mailman/listinfo/python-list
Ira wrote: OK let me rephrase,
the standard error stream (and if I'm not mistaken also the one that PyErr_Print() writes to) is the python object sys.stderr. Now say I'd go ahead and write the following in python...
SomeNewStreamOrFileOrWhateverItIs = new stream sys.stderr = SomeNewStreamOrFileOrWhateverItIs
I can go ahead and do the exact same thing from the C source code. All I need to do is to figure out how to wrap a c-style FILE* with a PyObject, And PySys_SetObjet("stderr", newstream);
I'm very new to python so that might be nonsense but it appeals to my programmer's common sense. Can anyone tell me how to do this? http://docs.python.org/api/fileObjects.html
--
Robert Kern rk***@ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
OK let me rephrase,
the standard error stream (and if I'm not mistaken also the one that
PyErr_Print() writes to) is the python object sys.stderr. Now say I'd go
ahead and write the following in python...
SomeNewStreamOrFileOrWhateverItIs = new stream
sys.stderr = SomeNewStreamOrFileOrWhateverItIs
I can go ahead and do the exact same thing from the C source code. All I
need to do is to figure out how to wrap a c-style FILE* with a PyObject, And
PySys_SetObjet("stderr", newstream);
I'm very new to python so that might be nonsense but it appeals to my
programmer's common sense. Can anyone tell me how to do this?
"Michael Hudson" <mw*@python.net> wrote in message
news:m2************@82-33-185-193.cable.ubr01.azte.blueyonder.co.uk... "Ira" <sh******@gmail.com> writes:
Using an embedded interpreter, how do I change it's default output streams (specifically the one used by PyErr_Print() which I'm guessing is the default error stream)?
It looks as though it writes to stderr unconditionally. But most of the reasons for ended up in PyErr_Print can be intercepted at a higher level (I think -- I mean sys.excepthook & co here).
Cheers, mwh
-- ARTHUR: Yes. It was on display in the bottom of a locked filing cabinet stuck in a disused lavatory with a sign on the door saying "Beware of the Leopard". -- The Hitch-Hikers Guide to the Galaxy, Episode 1 -- http://mail.python.org/mailman/listinfo/python-list
"Ira" <sh******@gmail.com> writes: OK let me rephrase,
the standard error stream (and if I'm not mistaken also the one that PyErr_Print() writes to) is the python object sys.stderr. Now say I'd go ahead and write the following in python...
Ah, OK, I think you're mistaken, and PyErr_Print prints to the C level
FILE* stderr (I agree my first post was confusing on this point, sorry
about that...).
Cheers,
mwh
--
<Acapnotic> jemfinch: What's to parse? A numeric code, perhaps a
chicken, and some arguments
-- from Twisted.Quotes
Michael Hudson wrote: "Ira" <sh******@gmail.com> writes:
OK let me rephrase,
the standard error stream (and if I'm not mistaken also the one that PyErr_Print() writes to) is the python object sys.stderr. Now say I'd go ahead and write the following in python...
Ah, OK, I think you're mistaken, and PyErr_Print prints to the C level FILE* stderr (I agree my first post was confusing on this point, sorry about that...).
No, it doesn't. It grabs the appropriate object from sys.stderr.
--
Robert Kern rk***@ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
Robert Kern <rk***@ucsd.edu> writes: Michael Hudson wrote: "Ira" <sh******@gmail.com> writes:
OK let me rephrase,
the standard error stream (and if I'm not mistaken also the one that PyErr_Print() writes to) is the python object sys.stderr. Now say I'd go ahead and write the following in python... Ah, OK, I think you're mistaken, and PyErr_Print prints to the C level FILE* stderr (I agree my first post was confusing on this point, sorry about that...).
No, it doesn't. It grabs the appropriate object from sys.stderr.
Ah, you're right, I somehow ended up reading PySys_WriteStderr...
Cheers,
mwh
--
The only problem with Microsoft is they just have no taste.
-- Steve Jobs, (From _Triumph of the Nerds_ PBS special)
and quoted by Aahz on comp.lang.python This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: radnoraj |
last post by:
Hi,
I am sucessfull in redirecting console output to a file. but in this
case nothing is displayed on the console, cout output is written to
file without display.
how do write the output to...
|
by: Gopal |
last post by:
Hi,
I've a module report.py having a set of funtions to open/close/write
data to a log file. I invoke these functions from another module
script.py.
Whenever I'm changing something in...
|
by: nobody |
last post by:
I am writing a framework that other developers will write plug-ins
for. I would like for one of the features of the framework to be to
intercept all text written to stdout/stderr and prepend...
|
by: Russ |
last post by:
I wrote a simple little function for exiting with an error message:
def error ( message ): print_stack(); exit ("\nERROR: " + message +
"\n")
It works fine for executing as a script, but when...
|
by: v4vijayakumar |
last post by:
is there any standard way to extract output from system(3) function?
TIA.
|
by: morris.slutsky |
last post by:
So every now and then I like to mess around with hobby projects - I
often end up trying to write an OpenGL video game. My last attempt
aborted due to the difficulty of automating game elements and...
|
by: nadeemabdulhamid |
last post by:
Hello,
I'm trying to write some Java code that will launch a python
interpreter shell and pipe input/output back and forth from the
interpreter's i/o streams and the Java program. The code posted...
|
by: castironpi |
last post by:
I'm curious about some of the details of the internals of the Python
interpreter:
I understand C from a hardware perspective.
x= y+ 1;
Move value from place y into a register
Add 1 to the...
|
by: Erik Hahn |
last post by:
I'm looking for a standalone Javascript interpreter like the ones of
Perl and Python. Does such a thing exist for Linux?
Thanks in advance.
-Erik
--...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |