On Mon, Aug 23, 2021 at 12:08 AM Dan Stromberg <drsali...@gmail.com> wrote: > > In 'from foo import bar': > > With the ast module, I see how to get bar, but I do not yet see how to get > the foo. > > There are clearly ast.Import and ast.ImportFrom, but I do not see the foo > part in ast.ImportFrom. > > ?
>>> import ast >>> ast.dump(ast.parse("from foo import bar")) "Module(body=[ImportFrom(module='foo', names=[alias(name='bar')], level=0)], type_ignores=[])" >>> ast.parse("from foo import bar").body[0].module 'foo' ChrisA -- https://mail.python.org/mailman/listinfo/python-list