13 Mar 17:49
Re: How to forbid a standard output of OpenOpt solvers
From: Mclean Edwards <mcleane <at> math.ubc.ca>
Subject: Re: How to forbid a standard output of OpenOpt solvers
Newsgroups: gmane.comp.python.scientific.user
Date: 2008-03-13 16:49:51 GMT
Subject: Re: How to forbid a standard output of OpenOpt solvers
Newsgroups: gmane.comp.python.scientific.user
Date: 2008-03-13 16:49:51 GMT
On Thu, 13 Mar 2008, 302302 wrote:
> Hi,
> I've used linear solver (cvxopt_glpk) from OpenOpt. Can I somehow forbid a printing description of
solving problem to the standard output?
> I supposed there should be some parameter in the running command, but I can't find any useful
documentation with this topic.
>
My clunky solution to this problem in general is by defining a class:
class StandardOutputEater:
def write(self, string):
pass
Then when I need to disable standard output:
#turn off standard output
saveout = sys.stdout
sys.stdout = StandardOutputEater()
When you want standard output again, call:
sys.stdout = saveout
This gets the job done in all such cases.
This is also useful to quickly turn off some self-reporting messages every
once and a while. (Such as when you demo some code still under
development to an interested party.)
Cheers,
Mclean
RSS Feed