title: Example ast code to parse Python source to extract docstring after global variables
body: <p>While Python does not officially support docstrings for global variables, it is common to add them anyway:</p>
  
  <pre><code>debug = False
  '''Set debug to True to see lots of intermediate results'''
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/8820276/docstring-for-variable">Docstring for variable</a> explains that Python does not directly offer access, but Sphinx is able to pull these out of a module. For something I am working on, I would like to access them as well. I think the ast module can do this. Anyone have any example code (using ast or other standard libraries) that can provide docstrings for variables defined in a module?</p>