Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > how to stop info output on screen

Reply
Thread Tools

how to stop info output on screen

 
 
midday.hu@gmail.com
Guest
Posts: n/a
 
      09-30-2005
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

 
Reply With Quote
 
 
 
 
Ido.Yehieli@gmail.com
Guest
Posts: n/a
 
      09-30-2005
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.

 
Reply With Quote
 
 
 
 
Ido.Yehieli@gmail.com
Guest
Posts: n/a
 
      09-30-2005
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.

 
Reply With Quote
 
Steve Holden
Guest
Posts: n/a
 
      09-30-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) 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/

 
Reply With Quote
 
Ido.Yehieli@gmail.com
Guest
Posts: n/a
 
      09-30-2005
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Newbie: How do I filter output to the screen and writing the orginal output to a file? Mav Perl Misc 22 07-09-2004 09:56 PM
parse output screen ok but cant get desired output new file! chuck amadi Python 1 06-23-2004 02:16 PM
How to stop a thread without using stop() Son KwonNam Java 11 04-09-2004 08:01 PM
Stop Debugging doesn't stop in ASP.NET Matt Theule ASP .Net 7 07-24-2003 07:38 PM



Advertisments