2

When importing the SMTPHandler, why does this approach work:

>>> from logging.handlers import SMTPHandler
# <class 'logging.handlers.SMTPHandler'>

But this one does not?

>>> import logging
>>> logging.handlers.SMTPHandler
# AttributeError: module 'logging' has no attribute 'handlers'

Often the second approach does work, but I'm wondering for the logging module why that doesn't import down the dot path?

David542
  • 104,438
  • 178
  • 489
  • 842

0 Answers0