On Sun, Aug 22, 2021 at 7:14 AM Chris Angelico <ros...@gmail.com> wrote:
> 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' > With 'from . import bar', I get a module of None. Does this seem strange? -- https://mail.python.org/mailman/listinfo/python-list