title: Error handling netCDF file in Python
body: <p>I am extracting data from netCDF files with Python code. I need to check if the netCDF files are in agreement with the CORDEX standards (CORDEX is a coordinated effort to carry modelling experiments with regional climate models). For this I need to access an attribute of the netCDF file. If the attribute is not found, then the code should go to the next file.  </p>
  
  <p>A snipet of my code is as follows:</p>
  
  <pre><code>import netCDF4
  
  cdf_dataset = netCDF4.Dataset(file_2read)
  
  try:
      cdf_domain = cdf_dataset.CORDEX_domain
      print(cdf_domain)
  
  except:
      print('No CORDEX domain found. Will exit')
      ....some more code....
  </code></pre>
  
  <p>When the attribute "CORDEX_domain" is available everything is fine. If the attribute is not available then the following exception is raised.</p>
  
  <pre><code>AttributeError: NetCDF: Attribute not found
  </code></pre>
  
  <p>This is a third party exception, which I would say should be handled as a general one, but it is not, as I am not able to get my "print" inside the "except" statement to work or anything else for that matter. Can anyone point me the way to handle this? Thanks.</p>