do not print results from get_parse to stderr
boompig opened this issue ยท 7 comments
Currently get_parse
always outputs results to stderr. Is there a way to run this function silently? This is especially annoying when crawling or running in Jupyter notebook.
thanks for the quick response. consider making this the default?
Hmm. That might be a good idea. Anyone else have a preference? (thinking about it)
While on the subject, is there a way for errors not to be printed as well, while using "silent=True"?
I'm searching for pages by name, and sometimes they don't exist. I handle it, but the error of not finding the page is still showing up.
Yes @TsUNaMyWaVe, try catching the exception raised, probably LookupError
. Something like this?
try:
<your code>
except LookupError:
pass
@siznax thanks! I actually found a little bit cleaner solution:
with contextlib.redirect_stderr(io.StringIO()):
<your code>
But I think adding this option as part of the tool could be a good improvement as well. By either adding it to the "silent" argument, or adding an additional argument for error printing.
@TsUNaMyWaVe thanks for the suggestion. In the case of an error, redirecting to stderr
seems appropriate. Still trying to decide if "silent by default" is best. Any opinion on that?