title: Ignoring error raise while iterating through files with python
body: <p>I'm currently working on a task where I need to iterate multiple executable file using pefile module the code is look like this</p>
  
  <pre><code>while True:
      try:
          for filename in glob.iglob('C:\Documents and Settings\Zha\Desktop\PE benign\*.exe'):
              pe =  pefile.PE(filename)
  
              print '%x' % pe.FILE_HEADER.NumberOfSections
  
      except:
          pass
  </code></pre>
  
  <p>My intention using try and except is to overcome error raise whenever an executable that raising an error where NT header gives Invalid signature because if I do not use try and except the code will stop at the point where it found an executable with invalid NT header signature</p>
  
  <p>this is what the message looks like if I don't use try and except</p>
  
  <pre><code>PEFormatError: 'Invalid NT Headers signature.' 
  </code></pre>
  
  <p>However using the code above will cause an infinite loop, is there any possible way to solve this?</p>