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
  • 101,766
  • 154
  • 423
  • 727

0 Answers0