def find_imports(filename):
    """Find all imported names in a given file.

    Returns a list of ImportInfo objects.
    """
    with open(filename) as f:
        root = ast.parse(f.read(), filename)
    visitor = ImportFinder(filename)
    visitor.visit(root)
    return visitor.imports
def find_imports ( filename ) : with open ( filename ) as f : root = ast . parse ( f . read ( ) , filename ) visitor = ImportFinder ( filename ) visitor . visit ( root ) return visitor . imports
Find all imported names in a given file.

    Returns a list of ImportInfo objects.