This is my project structure (Python 3.5.1.):

```
a
├── b.py
└── __init__.py

```

Case 1
------

* File `b.py` is empty.
* File `__init__.py` is:

```
print(b)

```

If we run `import a`, the output is:

```
NameError: name 'b' is not defined

```

Case 2
------

* File `b.py` is empty.
* File `__init__.py` is:

```
import a.b
print(b)

```

If we run `import a`, the output is:

```
<module 'a.b' from '/tmp/a/b.py'>

```

Question
--------

Why doesn't the program fail in Case 2?

Usually if we run `import a.b` then we can only reference it by `a.b`, not `b`. Hopefully somebody can help explain what's happening to the namespace in Case 2.