title: Python Exception Not Printing Statement Within Except Block
body: <p>I have a simple loop going in my code that is supposed to read in a bunch of dicts. Sometimes, json throws a <code>ValueError</code> while loading (i.e. the <code>part_row = json.loads(part)</code> line), and I want to catch this so my program can just continue.</p>
  
  <pre><code>log = logging.getLogger(__name__)
  for part in output_rows:
      try:
          part_row = json.loads(part)
          # log.warn('%s', part_row['name'])
      except ValueError:
          log.warn('part "%s" is bad to json', part)
          continue
  </code></pre>
  
  <p>Everything works normally with the try/except EXCEPT for the logging. For some reason, the log statement in the except statement is never done (or doesn't seem to be) <strong>unless</strong> the other log statement is uncommented. Note that this also happens if I use print instead of log. This seems like black magic to me.</p>
  
  <p>If anyone has any insights into this, it would be greatly appreciated.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Somehow, today, I came back to the code, commented out that line, and the code worked fine, logging happened exactly as it was supposed to. I have no idea what happened. I've done that before. I'll chalk it up to programming black magic.</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>A friend of mine suggested it could have been due to outdated .pyc files. I don't really have a way of checking, but it's worth considering.</p>