I'm trying to use ast to open a .py file and for each class in the file, give me the attributes I want.
However, I can't get ast to behave as expected.
I'd expect to be able to do
import ast
tree = ast.parse(f)
for class in tree:
for attr in class:
print class+" "+attr.key+"="+attr.value
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).