I am using Python 3.3, testing this on Windows. I do not understand anything. Why when I do this:
>>> import urllib
I get an error
>>> urllib.request
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'request'
and
>>> dir(urllib)
['__builtins__', '__cached__', '__doc__', '__file__', '__initializing__',
'__loader__', '__name__', '__package__', '__path__']
There is no request, so it looks durable. However, when importing a submodule request:
>>> import urllib.request
It seems to work
>>> urllib.request
<module 'urllib.request' from 'C:\\Python33\\lib\\urllib\\request.py'>
And now it automatically dir(urllib)shows:
>>> dir(urllib)
['__builtins__', '__cached__', '__doc__', '__file__', '__initializing__',
'__loader__', '__name__', '__package__', '__path__', 'error', 'parse',
'request', 'response']
Why can't I see after import urlliball the submodules? According http://docs.python.org/3.3/library/urllib.html#urllib.urlopen it should be request, error, parse, parserobots. Is it different from other OS?