{"id":1225,"date":"2012-10-25T17:58:45","date_gmt":"2012-10-25T23:58:45","guid":{"rendered":"http:\/\/thesmithfam.org\/blog\/?p=1225"},"modified":"2019-08-12T07:15:07","modified_gmt":"2019-08-12T13:15:07","slug":"temporarily-suppress-console-output-in-python","status":"publish","type":"post","link":"https:\/\/thesmithfam.org\/blog\/2012\/10\/25\/temporarily-suppress-console-output-in-python\/","title":{"rendered":"Temporarily Suppress Console Output in Python"},"content":{"rendered":"<p>Have you ever wanted to temporarily suppress console output in Python? But you really want it to be temporary, even if an exception happens. Maybe you are calling into some idiot&#8217;s library who spams your console. Yeah, that&#8217;s happened to me before (maybe I was the idiot&#8211;I&#8217;m not tellin&#8217;).<\/p>\n<p>Here&#8217;s a handy way to suppress stdout temporarily in your program:<\/p>\n<p>First, slap this code into your project:<\/p>\n<p><script src=\"https:\/\/gist.github.com\/3956189.js?file=gistfile1.py\"><\/script><\/p>\n<p>Use it like this:<\/p>\n<p><script src=\"https:\/\/gist.github.com\/3956195.js?file=gistfile1.py\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever wanted to temporarily suppress console output in Python? But you really want it to be temporary, even if an exception happens. Maybe you are calling into some idiot&#8217;s library who spams your console. Yeah, that&#8217;s happened to me before (maybe I was the idiot&#8211;I&#8217;m not tellin&#8217;). Here&#8217;s a handy way to suppress [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-1225","post","type-post","status-publish","format-standard","hentry","category-code-and-cruft"],"_links":{"self":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts\/1225","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/comments?post=1225"}],"version-history":[{"count":11,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts\/1225\/revisions"}],"predecessor-version":[{"id":1247,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts\/1225\/revisions\/1247"}],"wp:attachment":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/media?parent=1225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/categories?post=1225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/tags?post=1225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}