Why do modules imported inside their package bring in their own module name

Viewed 18

I have a simple structure:

\package
  \__init__.py
  \module1.py

Inside __init__.py I have:

from . import module1 as another_name
print(dir())

When I open an interpreter and run import Test I will find that my namespace includes both module1 and another_name. Why does module1 appear in my namespace, when I've explictly told Python to call it something else?

0 Answers
Related