I am having trouble understanding the following behavior using Python 3.4.3:
In [1]: import urllib
In [3]: urllib.parse
Out[3]: <module 'urllib.parse' from '/home/laurent/anaconda/envs/springleaf/lib/python3.4/urllib/parse.py'>
In [4]: urllib.request
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-4-615cd424e6d8> in <module>()
----> 1 urllib.request
AttributeError: 'module' object has no attribute 'request'
I looked at urllib's package [myenv]/lib/python3.4/urllib, but its just empty __init__.py, and I can’t understand why the submodule parsewill be visible until the submodule requestor errornot.
The behavior I was expecting was to make all modules visible.
What causes a module to be visible parsewhile other modules are not?
I can use it from urllib import requestjust fine, but I would like to understand the reason for the behavior.
EDIT:
As recommended in the comments, I ran the same commands in a simple python shell (I used IPython 4.0.0 above):
>>> import urllib
>>> urllib.parse
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'parse'
>>> urllib.request
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'request'
. , .
, - , IPython;).