I don't have this problem, but it came to my mind while I was working on a related issue. Let's have:
logging = 'something' # bad naming decision
import logging as lg # using a different name
How do you import logging.config as lg.config without overwriting the original logging?
After some testing I found this:
import logging.config as _ # any unused name
But is it really correct? Are there better solutions?
How about doing something like this ?
import logging as lg
from logging import config
After this both config and lg.config refer to logging.config.
In [3]: config
Out[3]: <module 'logging.config' from 'C:\\Anaconda3\\lib\\logging\\config.py'>
In [4]: lg.config
Out[4]: <module 'logging.config' from 'C:\\Anaconda3\\lib\\logging\\config.py'>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With