module confusion
Robert Kern
robert.kern at gmail.com
Tue Oct 2 01:05:54 EDT 2007
mensanator at aol.com wrote:
> On Oct 1, 10:03?pm, rjcarr <rjc... at gmail.com> wrote:
>> Sorry if this is a completely newbie question ...
>>
>> I was trying to get information about the logging.handlers module, so
>> I imported logging, and tried dir(logging.handlers), but got:
>>
>> AttributeError: 'module' object has no attribute 'handlers'
>
> What do suppose that message means?
>
>> The only experience I have in modules is os and os.path ... if I do
>> the same thing, simply import os and then type dir(os.path), it
>> displays the contents as expected.
>>
>> So my question is ... why are they different?
>
> Because you misspelled it. First, do a dir() on logging:
No, he didn't. There is a logging.handlers module; it's just not imported by
importing logging.
OP: logging is a package and logging.handlers is one module in the package. Not
all of the modules in a package are imported by importing the top-level package.
os.path is a particularly weird case because it is just an alias to the
platform-specific path-handling module; os is not a package.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list
mailing list