Any adv. in importing a module and some objects in the same module, into the same file?
Piet van Oostrum
piet at cs.uu.nl
Sat Apr 18 17:54:03 EDT 2009
>>>>> Visco Shaun <visco31 at gmail.com> (VS) wrote:
>VS> http://docs.python.org/library/logging.html
>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'
directory.
--
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org
More information about the Python-list
mailing list