title: Retrieve value of netCDF global attribute by name in Python
body: <p>How do I retrieve the value of a global attribute from a netCDF file in Python by its name?</p>
  
  <p>I have tried:</p>
  
  <pre><code>value = ncfile.getncattr(ncfile, global_attribute_name)
  </code></pre>
  
  <p>but I get the error:</p>
  
  <pre><code>NameError: name 'global_attribute_name' is not defined
  </code></pre>
  
  <p>I have also read the section of the <a href="https://unidata.github.io/netcdf4-python/netCDF4/index.html" rel="nofollow noreferrer">netCDF4 API documentation</a> that deals with global attributes, but I'm sure there's something I don't understand with the syntax. </p>
  
  <p>Can anyone help? I'm an R user moving over to Python, please be gentle.</p>