Any adv. in importing a module and some objects in the same module, into the same file?

Piet van Oostrum piet at
Sat Apr 18 23:54:03 CEST 2009

>>>>> Visco Shaun <visco31 at> (VS) wrote:

>VS> While going thr' the above link i came across import statements 
>VS> "import logging
>VS> import logging.handlers"

>VS> What is the use of second import as the first import will be
>VS> enough(AFAIK) to access anything intended by the second import?
>VS> Is there any kind of advantage?

Have you tried?

>>> import logging
>>> logging.handlers
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'handlers'
>>> import logging.handlers
>>> logging.handlers
<module 'logging.handlers' from '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/logging/handlers.pyc'>

'logging' is a package. The 'logging' module does not contain a
definition of 'handlers' but there is a module 'handlers' in the 'logging'
Piet van Oostrum <piet at>
URL: [PGP 8DAE142BE17999C4]
Private email: piet at

More information about the Python-list mailing list