After importing a module, I can access some of its submodules directly
but others require an explicit import of the submodule.

As an example, see ldap.dn and ldap.modlist:

% python
Python 2.7.8 (default, Aug  4 2016, 09:29:33)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ldap
>>> ldap.__version__
'2.4.19'
>>> ldap.modlist
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'modlist'
>>> ldap.dn
<module 'ldap.dn' from 
'/opt/rh/python27/root/usr/lib64/python2.7/site-packages/ldap/dn.pyc'>
>>> import ldap.modlist
>>> ldap.modlist
<module 'ldap.modlist' from 
'/opt/rh/python27/root/usr/lib64/python2.7/site-packages/ldap/modlist.pyc'>

Why the difference?

-- 
John Gordon                   A is for Amy, who fell down the stairs
gor...@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to