Using Python's ast to get attributes from a class
<p>I'm trying to use ast to open a .py file and for each class in the file, give me the attributes I want.</p>

<p>However, I can't get ast to behave as expected.</p>

<p>I'd expect to be able to do</p>

<pre><code>import ast

tree = ast.parse(f)
for class in tree:
    for attr in class:
        print class+" "+attr.key+"="+attr.value
</code></pre>

<p>For example; a bit like ElementTree with XML.  Or maybe I've got the totally wrong idea behind ast, in which case, is it possible to do this another way (if not, I'll write something to do it).</p>
