Why Are Both "Import Logging" and "Import Logging. Config" Needed?
Should It Not Be Handled by a Single Import? I. E. Import Logging. If I Do Not Include Import Logging. Config in My Script, It Gives: Attributeerror: 'Module'...
Should it not be handled by a single import? i.e. import logging.
If I do not include import logging.config in my script, it gives:
AttributeError: 'module' object has no attribute 'config'
2 Answers
logging is a package. Modules in packages aren't imported until you (or something in your program) imports them. You don't need both import logging and import logging.config though: just import logging.config will make the name logging available already.
Just add an addtional explanation for Thomas's answer.
logging is a package, a directory.
enter the logging dir and list what files there is:
config.py handlers.py __init__.py __pycache__
so, There is a config.py file in logging directory, but why it can't import logging.config. That's because there is no config namespace in logging/__init__.py