I\'m having difficulty understanding the import statement and its variations.
Suppose I\'m using the lxml module for scraping websites.
The followin
Let's take an example of a package pkg with two module in it a.py and b.py:
--pkg
|
| -- a.py
|
| -- b.py
|
| -- __init__.py
in __init__.py you are importing a.py and not b.py:
import a
So if you open your terminal and do:
>>> import pkg
>>> pkg.a
>>> pkg.b
AttributeError: 'module' object has no attribute 'b'
As you can see because we have imported a.py in pkg's __init__.py, we was able to access it as an attribute of pkg but b is not there, so to access this later we should use:
>>> import pkg.b # OR: from pkg import b
HTH,