[SciPy-user] keep scipy quiet

Joe Harrington jh at oobleck.astro.cornell.edu
Mon Dec 12 10:38:41 CST 2005


> how can I get rid of the "importing <package> to scipy" messages.

I agree with Steve and Cory.  The diagnostics are useful in some
circumstances, particularly interactive use, when debugging your own
code, etc.  But, it is important to be able to turn all
non-user-commanded output off before any occurs.  For example, say you
are writing a stand-alone Python script to perform some mathematical
operation in a Unix shell pipeline (what Cory was saying):

% pyreaddata | pycomputefft | someplottingprogram --xyplot --coloneisy

Without some way of turning off all babble from Python, you'd have to
stick an ugly sed command after every py* command to strip the
diagnostics out - and hope you got all possible babble anyone might
think of to include in the future.  Maybe the way to do it is to have
a global diagnostic status to set:

-3, etc	etc
-2	even more debugging output
-1	debug mode, print basic debugging messages
0	default, interactive mode, print normal diagnostics
1	quiet mode, print only critical error messages
2	don't even print critical error messages, just die with a status

The last option is useful if the program is going to be writing binary
data files and there is no way anyone is going to go looking for text
messages in them (though such messages should go to stderr anyway).

I'm not suggesting a particular implementation here, just that the
diagnostic status should be visible any time a diagnostic print might
occur (which is pretty much anywhere).

Lacking that, all diagnostic babble should start with the same
constant string to make filtering it out with sed easy:

DIAG: Importing test to scipy
DIAG: Importing base to scipy
...

That way, if next year someone updates a package to include a new
diagnostic, it doesn't break my old code that filters diagnostics.

But, it would be better just to be able to turn them off.

If there's already a way to do this, it needs to be documented better...

--jh--



More information about the SciPy-user mailing list