On Fri, 8 Apr 2022, 17:44 Guido van Rossum, <guido@python.org> wrote:
The interesting idea here seems to make "lazy imports" easier to implement by making them explicit in the code. So far, most lazy import frameworks for Python have done hacks with `__getattribute__` overrides. 

The value is more than ease of implementation. Having syntax for import expressions makes them statically analysable, which is needed for type checkers and IDE autocompletion.

But I also see value in being able to type out code that uses modules not yet imported without breaking my flow to add an import statement. I don't yet trust IDEs to do this because I've been bitten by them doing so incorrectly in the past.

The key questions to me are
- What should the notation be?

I would like to bid again for (import package.module) as an expression. Instead of doing the import and assigning package to a variable package it would evaluate to the module object package.module.

The `as` form is not needed because no name is assigned and the `from` form isn't as valuable because you can just use attribute access afterwards.

It isn't terse but it does make use of the import keyword and is thus instantly recognisable. It is even syntax highlighted correctly by much existing software. If we're using the import keyword then I think it has to look like this.

But I concede that it isn't particularly elegant to type hint things with

(import collections.abc).Mapping

...but not so inelegant that I couldn't see myself using it for a few one-off imports per module.

A quirk is that it means there's a big difference between the statements

import foo

and

(import foo)

because one assigns a variable. I don't mind that; I don't think it is too ambiguous to a reader.