471,353 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

howto run a function w/o text output?

hi all,
I have a
y = some_func(args)
statement, and the some_func() produces lots of text output. Can I
somehow to suppress the one?
Thx in advance, D.

Jun 22 '07 #1
3 5380
dmitrey schrieb:
hi all,
I have a
y = some_func(args)
statement, and the some_func() produces lots of text output. Can I
somehow to suppress the one?
Thx in advance, D.
Either rewrite it or pipe sys.stdout to some other file-like object but
your console while running it. The StringIO
(http://docs.python.org/lib/module-StringIO.html) module might help.
Jun 22 '07 #2
On Jun 22, 9:56 am, dmitrey <open...@ukr.netwrote:
hi all,
I have a
y = some_func(args)
statement, and the some_func() produces lots of text output. Can I
somehow to suppress the one?
Thx in advance, D.
Expand|Select|Wrap|Line Numbers
  1. import sys
  2. import os
  3.  
  4. sys.stdout = open(os.devnull,"w")
  5.  
Jun 22 '07 #3
On 6/22/07, dmitrey <op*****@ukr.netwrote:
hi all,
I have a
y = some_func(args)
statement, and the some_func() produces lots of text output. Can I
somehow to suppress the one?
Thx in advance, D.
In addition to the other solutions proposed, on a *nix system you can
do os.close(1); os.close(2) to suppress output to stdout and stderr.

--
Evan Klitzke <ev**@yelp.com>
Jun 22 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Topper | last post: by
8 posts views Thread by mosscliffe | last post: by
12 posts views Thread by Stef Mientki | last post: by

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.