title: Suppress pygame debug output (console output)
body: <p>Apparently the version of pygame I'm using has an issue where debug statements have been left in - <a href="https://stackoverflow.com/questions/2125702/how-to-suppress-console-output-in-python">How to suppress console output in Python?</a> while using <code>joystick.get_axis</code>. That is the issue, but I have been unsuccessful in trying to use the methods presented in those answers. Each of the methods still printed the <code>SDL_JoystickGetAxis value</code>.</p>
  
  <p>I also tried  <a href="http://thesmithfam.org/blog/2012/10/25/temporarily-suppress-console-output-in-python/" rel="nofollow noreferrer">this blog</a> but I was still outputting to the console. Thinking it may be an issue with <code>stdout</code> vs <code>stderr</code>, I tried suppressing <code>stdout</code> then <code>stderr</code> then both, to no avail. </p>
  
  <p>Basically my code is constantly printing <code>SDL_JoystickGetAxis value:0</code> or whatever the axis value is. How do I suppress these debug statements?</p>
  
  <pre><code>import os
  import sys
  from contextlib import contextmanager
  
  @contextmanager
  def suppress_stdout():
      with open(os.devnull, 'w') as devnull:
          old_stdout = sys.stdout
          sys.stdout = devnull 
          try:
              yield
          finally:
              sys.stdout = old_stdout
  </code></pre>
  
  <p>Later on in my code I use that function: </p>
  
  <pre><code>    if speedchange == False and headingchange == False:
          time.sleep(0.1)
          with suppress_stdout():
              speed_ax = joys.get_axis(1)
              head_ax = joys.get_axis(0)
  </code></pre>
  
  <p>Which still outputs debug statements</p>