473,385 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how to stop info output on screen

Hi,

Does someone know how to stop "the information output on screen"? Now
when I run my code, it outputs a lot of message when calling other
libraries, together with the info with the print command I used.

How can I mask these info on screen when calling other libraries and
how I can mask the info output produced by the print command? Is there
a way to mask them separately.

Thanks a lot if anyone knows it.

Kind regards of your help
Midday

Sep 30 '05 #1
4 3788
maybe you can try replaceing sys.stdout and/or sys.stderr with a just a
simple file? then everything will be written to that file instead of
desplayed on the console.

Cheers,
Ido.

Sep 30 '05 #2
more on the subject: your "print" statments will also be written to
that file that sys.stdout directs to, so maybe that wasn't exactly the
solution you wanted to hear.

ok, not the nicest solution but maybe it will help you anyway:
bind sys.stdout at the begining of the program to a file (don't forget
to save it first! let's say stdout = sys.stdout;
sys.stdout=file('myLogFile.dat','w') ), and write your own print
funktion that goes something like that:
def printToConsole(stringToPrint,oldStdOut):
____sys.stdout=oldStdOut
____print stringToPrint
____sys.stdout=file('myLogFile.dat','w')

then when you want to print to the console, use this function instead
of the print statment. all the rest will go to 'myLogFile.dat'

Cheers,
Ido.

Sep 30 '05 #3
mi*******@gmail.com wrote:
Hi,

Does someone know how to stop "the information output on screen"? Now
when I run my code, it outputs a lot of message when calling other
libraries, together with the info with the print command I used.

How can I mask these info on screen when calling other libraries and
how I can mask the info output produced by the print command? Is there
a way to mask them separately.

Thanks a lot if anyone knows it.

Kind regards of your help
Midday

Since you appear to be adding your own code, with your own print
statements, to an existing Python program the easiest thing to do is
make sure your own code writes to a place of your choice. This is most
easily done with

myFile = open("myfile.txt", "w")
...
print >> myFile, this, that, the other
...
print >> myFile, moreStuff(things)
...
myFile.close()

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Sep 30 '05 #4
forget my posts, Steve's solution is much more maintanable when you(or
someone else)'ll revisit the code in a couple of years.

i would go with what he wrote.

Cheers,
Ido.

Sep 30 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: siggy2 | last post by:
Hi All, (sorry for my bad english) I wrote a __tiny__ and __stupid__ recursive script directly into pythonwin interactive window with a time.sleep(1) and a print before each recursion... I...
5
by: Tom Petersen | last post by:
I am using a response.write to test the formatting of the output. I am supposed to get this: BEGIN:VCALENDAR VERSION:1.0 BEGIN:VEVENT DTSTART:20051022T090000Z DTEND:20051022T090000Z...
4
by: rossum | last post by:
I have been looking at exceptions as I need to get better at using them. I came across an interesting effect, demonstrated below. When I ctrl-Z the input to throw an ios_base::failure, the...
9
by: Nick Forrington | last post by:
Hi, I'm making a program and have a static Console class that I'm using to output things, these get sent to the console and also to the graphics on screen (I'm using SDL). One thing I'm having a...
2
by: TS | last post by:
when i try to do a response.flush and .end, the screen ends up blank. I want all page processing to quit when a check in the pageload event fails. Since control events occur after load, how do i...
2
by: Key9 | last post by:
Question about basic input output. HI All I am a new C++er Suppose I am designing a i/o device . system have screens . system have keyboards.
2
by: Thirsty Traveler | last post by:
Is there an easy way to stop the annoying screen flashing when doing a postback?
20
by: Tim Reynolds | last post by:
Team, I am developing a web service. In testing in on my enw PC, I am expecting to see exceptions thrown appear on my browser. Instead I am getting an HTTP 500 Internal Server Error page and I am...
2
by: e_matthes | last post by:
Hello all, Say I have the following string: $string = "list of whales: white beluga whale humpback whale atlantic humpback whale"; I want to pull out the first kind of whale (white beluga)....
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.