is there an ast python3 documentation? (At least for the Syntax)
Question: Im trying to work with the ast class in python. I want to get all Function
calls and their corresponding arguments.

How can I Implement that? The official Documentation on python.org is really
vague.

Also i tried implementing visit_Name and visit_Call. But that gives me more
than the names of the Call. It would be nice if there were some documentation
which attributes which nodes possesses. For example id for Name-nodes and func
for Call-nodes.


Answer: I know of no other documentation, but a lot can be learned by studying
examples, such as [this one](http://stackoverflow.com/a/1515403/190597), by
Alex Martelli. You could start by modifying it just slightly, this way:

    
    
    import ast
    
    class FuncVisit(ast.NodeVisitor):
        def __init__(self):
            self.calls = []
            self.names = []
        def generic_visit(self, node):
            # Uncomment this to see the names of visited nodes
            # print(type(node).__name__)
            ast.NodeVisitor.generic_visit(self, node)
        def visit_Name(self, node):
            self.names.append(node.id)
        def visit_Call(self, node):
            self.names = []
            ast.NodeVisitor.generic_visit(self, node)
            self.calls.append(self.names)
            self.names = []        
        def visit_keyword(self, node):
            self.names.append(node.arg)
    
    tree = ast.parse('''\
    x = foo(a, b)
    x += 1
    bar(c=2)''')
    v = FuncVisit()
    v.visit(tree)
    print(v.calls)
    

yields

    
    
    [['foo', 'a', 'b'], ['bar', 'c']]
    

