I'm having difficulty understanding the import statement and its variations.
Suppose I'm using the lxml
module for scraping websites.
The following examples show...
from lxml.html import parse
parse( 'http://somesite' )
...Google's python style guide prefers the basic import statement, to preserve the namespaces.
I'd prefer to do that, but when I try this:
import lxml
lxml.html.parse( 'http://somesite' )
...then I get the following error message:
AttributeError: 'module' object has no attribute 'html'
Can anyone help me understand what is going on? I'd much prefer to use modules within their namespaces, but need some assistance understanding the semantics.