I thought I understood what "import *" did and its potential dangers, but obviously not.
I've got:
foo.py:
from datetime import datetime
from bar import *
print(datetime.now())
bar.py:
import datetime
The result of running foo.py is an exception:
AttributeError: module 'datetime' has no attribute 'now'
datetime is a module, but datetime.datetime is a type. from datetime import datetime makes it so that datetime in foo.py refers to the type, but the subsequent from bar import * somehow makes it again refer to the module.
Removing the from bar import * makes the exception go away.
But why does from bar import * pollute my namespace with the module datetime? datetime is a module imported in bar, but it isn't defined there. What am I missing?
 
    