title: How to do debugging prints in Python?
body: <p>I have a function like this....</p>
  
  <p><code>def validate_phone(raw_number, debug=False):</code></p>
  
  <p>I want the debug flag to control whether it outputs logging statements. For example:</p>
  
  <pre><code>if (debug):
    print('Before splitting numbers', file=sys.stderr)
  
  split_version = raw_number.split('-')
  
  if (debug):
    print('After splitting numbers', file=sys.stderr)
  </code></pre>
  
  <p>That code is very repetitive however.  What is the cleanest (DRYest?) way to handle such if-flag-then-log logic?</p>