On Wed, Mar 14, 2018 at 4:58 PM, Steven D'Aprano <st...@pearwood.info> wrote:
> On Wed, Mar 14, 2018 at 04:20:20PM +1100, Chris Billington wrote:
>> Instead, maybe a user should just get a big fat error if they try to import
>> the same file twice under different names.
> Absolutely not.
> Suppose I import a library, Spam, which does "import numpy".
> Now I try to "import numpy as np", and I get an error.
That's not the same thing. Both of those statements are importing the
same file under the same name, "numpy"; one of them then assigns that
to a different local name. But in sys.modules, they're the exact same
The double import problem comes when the same file gets imported under
two different names *in sys.modules*. Everything else isn't a problem,
because you get the same module object - if you "import numpy; import
numpy as np; assert np is numpy", you're not seeing a double import
Python-ideas mailing list
Code of Conduct: http://python.org/psf/codeofconduct/