[Python-ideas] Disallow importing the same module under multiple names
ncoghlan at gmail.com
Wed Mar 21 07:32:39 EDT 2018
On 20 March 2018 at 16:25, Gregory P. Smith <greg at krypto.org> wrote:
> On Thu, Mar 15, 2018 at 3:26 AM Nick Coghlan <ncoghlan at gmail.com> wrote:
>> If we did head in this direction, then we'd also need to accept &
>> implement PEP 499  (which proposes aliasing __main__ as
>> __main__.__spec__.name in sys.modules when executed with "-m") to avoid
>> causing problems.
> I don't doubt that doing this would require a lot of code cleanup. :)
I was recently reminded of a "fun" edge case for PEP 499: "python -m site",
which reruns a module that gets implicitly imported at startup (so "site"
is already in sys.modules by the time __main__ runs).
That said, the way that currently works (re-running sitecustomize and
usercustomize) isn't particularly wonderful, so proposing changing it would
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas