On 4/8/2022 12:51 PM, Daniel Pope wrote:
On Fri, 8 Apr 2022 at 12:23, Steve Dower <steve.do...@python.org> wrote:

I've read the rest of the thread so far, and agree strongly that we
can't do this at the language/runtime level.

You mean the hoisting, right?

I don't see any reason why an import expression without hoisting would
be impractical. But I'd like to hear your thoughts if you think it is.

Sure, __import__() or better yet, importlib.util.import_module() are perfectly good ways to do an import in an expression. Both have exactly the right amount of code-smell as well, and only a few surprising ways to interfere with the behaviour of apparently completely unrelated code ;)

As others pointed out, implicitly defining variables that outlive the evaluation of an expression is incredibly messy. It was bad enough getting assignment expressions defined well enough to (a) not be a terrible footgun and (b) be possible for the average developer to predict what will happen when they're used (arguably this isn't true either, but the "average" developer probably isn't doing things that will hit the edge cases).

We don't want to have to figure something like that out again. Certainly not for the sake of typing - the SC has already ruled that language development won't be driven by the convenience of static type users.

Cheers,
Steve

_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/SRAIPD7DQH36DNBZVEAA6I56IZHLGA66/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to